Contributor
2720 Points
874 Posts
Jul 13, 2020 08:51 AM|Rena Ni|LINK
Hi Buronya Kofi,
You could set the ConnectionString(What I marked as green could be changed by yourself ) in the appsettings.json like below:
"ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=YourDatabaseName;Trusted_Connection=True;MultipleActiveResultSets=true" }
And get the connnection string like below:
services.AddDbContext<YourDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
Reference:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/working-with-sql?view=aspnetcore-3.1&tabs=visual-studio
Best Regards,
Rena
Contributor
2720 Points
874 Posts
Re: appsettings.json
Jul 13, 2020 08:51 AM|Rena Ni|LINK
Hi Buronya Kofi,
You could set the ConnectionString(What I marked as green could be changed by yourself ) in the appsettings.json like below:
And get the connnection string like below:
Reference:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/working-with-sql?view=aspnetcore-3.1&tabs=visual-studio
Best Regards,
Rena