{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"AuthConnectionString": "Server=.;Database=EmployeeLeaveDatabase;Trusted_Connection=True"
}
在這里請檢查
builder.Services.AddDbContext<AuthDbContext>(options => options.UseSqlServer(
builder.Configuration.GetConnectionString("AuthConnectionString")));
builder.Services.AddIdentity<IdentityUser, IdentityRole>().AddEntityFrameworkStores<AuthDbContext>();
我試圖添加遷移,但不知道為什么會收到此錯誤 System.ArgumentNullException: Value cannot be null。(引數“connectionString”)在 Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName) 在 Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction) 在 Program.<>c__DisplayClass0_0。 <$>b__0(DbContextOptionsBuilder 選項) 在 C:\Users\Seventhball\source\repos\EmployeeLeaveManagement\EmployeeLeaveManagement\Program.cs:line 9
uj5u.com熱心網友回復:
如果這樣定義:
"AuthConnectionString": "Server=.;Database=EmployeeLeaveDatabase;Trusted_Connection=True"
用這個:
builder.Configuration.GetValue<string>("AuthConnectionString")
如果你這樣定義它:
"ConnectionStrings": { "AuthConnectionString": "Server=.;Database=EmployeeLeaveDatabase;Trusted_Connection=True;"}
用這個: :
builder.Configuration.GetConnectionString("AuthConnectionString")
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/407997.html
標籤:
上一篇:從查詢中的日期時間中洗掉時間
