vansomething
vansomething

Reputation: 21

Connecting ASP.NET Core to SQL server

I am learning ASP.NET framework. I have created a simple To Do List with React.js on the front end, and ASP.NET Core on the backend. It seems I am connecting to the database with no problems. But I have added a simple table to the server for the purposes of testing the connection which look something like this: 1 Create a To Do List but when I launch the app on localhost, nothing is displayed, as depicted in this picture loading..., which suggests the back end is not functioning properly. Here is my connection string: "DBConString": "jdbc:sqlserver://localhost;database=master" and other relevant connection info```

        {
            services.AddControllersWithViews();
            var ConnectionString = Configuration.GetConnectionString("DBConString");
            services.AddDbContext<ToDoListDBContext>(options =>
                options.UseSqlServer(ConnectionString));
            services.AddMvc();
            services.AddCors();```

    app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=ToDosController}/{action=Index}/{id?}");
            });

Also some screenshots that show my successful connection to the database in my IDE: successful connection to database in Rider If anyone could share some insight into why this is not working, it'd be much appreciated!

Upvotes: 1

Views: 1538

Answers (1)

Slava Knyazev
Slava Knyazev

Reputation: 6081

ConnectionStrings in .NET Core have a special format that needs to be followed.

Take a look here to see what you need: https://www.connectionstrings.com/sql-server/

Upvotes: 2

Related Questions