我使用 .Net 6,当我想运行我的第一次迁移时,我收到了这个错误:
值不能为空。(参数“连接字符串”)
我的appsettings.json
:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=Solardb;integrated security=SSPI"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
这是我的Configuration
方法program.cs
:
builder.Services.AddDbContext<SolarDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("ConnectionStrings")));