📜  用户的脚手架 dbcontext 登录失败 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:26.693000             🧑  作者: Mango

代码示例1
When I use the PMC in Visual Studio and try to Scaffold-DbContext with 
Scaffold-DbContext “Data Source=localhost;Database=Library;Integrated Security=True” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
I get error login failed.
The correct way to go about it is to get the connection string for the database from View->Sql Server Object Explorer and go to the Properties of the Database. Use the connection string from there
So in this specific case the correct PMC command was:
Scaffold-DbContext “Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Library;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models