1、向文件添加一个连接字符串appsettings.Development.json(嵌套在 下appsettings.json):
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"Conn": "Server=.\\SQLEXPRESS;Database=FinanceInfo;Trusted_Connection=True;user id =sa;password=;"
}
}
2、生成类
安装后,项目右键ef core 工具-反向工程生成类
3、programs.cs
builder.Services.AddSqlServer<FinanceInfoContext>(builder.Configuration.GetConnectionString("Conn"));
标签:Core,Power,appsettings,builder,EF,json,Tools From: https://www.cnblogs.com/Biyuanguang/p/18031937