My ASP.Net Core app keeps trying to login into database using a "default" username even though I specify a different user in a connection string, which I am using. That is I keep getting the same exception that says:
An unhandled exception occurred while processing the request. SqlException: Cannot open database "testDB" requested by the login. The login failed. Login failed for user 'DESKTOP-555DDD\skorejen'.
Even though I am using a connection string that has a different username defined.
How can I fix it so that my app logins with the connection-string specified username?
Connection String:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=testDB;User Id=myusername;Trusted_Connection=True;"
},
ASP.Net Core Startup.cs file:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<OrderContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
}
