[英]Can't create migration in asp.net core 2.0
我正在嘗試創建身份遷移是ASP.NET Core 2.0,並且出現錯誤。
System.Data.SqlClient.SqlException(0x80131904):無法打開登錄請求的數據庫“ MarketIdentity”。 登錄失敗。
Appsettings.json
"MarketIdentity": {
"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=MarketIdentity;Trusted_Connection=True;MultipleActiveResultSets=true"
}
startup.cs
public void ConfigureServices(IServiceCollection services)
{
//services.Configure<AppSettings>(Configuration.GetSection("Data:Market"));
services.AddMvc();
//app database
services.AddDbContext<EfDbContext>(
options => options.UseSqlServer(Configuration["Data:Market:ConnectionString"],
b => b.MigrationsAssembly("Market")));
//identity database
services.AddDbContext<AppIdentityDbContext>(
options => options.UseSqlServer(Configuration["Data:MarketIdentity:ConnectionString"],
b => b.MigrationsAssembly("Market")));
services.AddIdentity<IdentityUser, IdentityRole>(options => {
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequireLowercase = false;
options.Password.RequireDigit = false;
})
.AddEntityFrameworkStores<AppIdentityDbContext>();
}
嘗試這個
"ConnectionStrings": {
"MarkIdentity": "Server=(localdb)\\mssqllocaldb;Database=MarketIdentity;Trusted_Connection=True;MultipleActiveResultSets=true"
}
services.AddDbContext<EfDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MarkIdentity")));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.