简体   繁体   中英

.NET EF update database does not try to connect to database

I have the following connection string:

builder.Services.AddDbContext<ApplicationDbContext>(options =>
     options.UseSqlServer("Server=localhost;Database=SuperDB;User Id=sa;Password=MYPASSWORD;Trusted_Connection=True;MultipleActiveResultSets=true"));

However when .NET EF database update , it does not create anything and just says (even if I enter a wrong password)

Entity Framework Core 6.0.2 initialized 'ApplicationDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.2' with options: None

It does work locally if I remove the credentials and replace the server to (localdb)\MSSQLLocalDB , my default local server for SQL Server databases. Am I missing something?

As AlwaysLearning said in the comments, removing Trusted_Connection=True; works as it causes the connection to use Windows Authentication (which works well locally obviously).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM