I am trying to create Identity migration is ASP.NET Core 2.0 and getting error.
System.Data.SqlClient.SqlException (0x80131904): Cannot open database "MarketIdentity" requested by the login. The login failed.
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>();
}
try this
"ConnectionStrings": {
"MarkIdentity": "Server=(localdb)\\mssqllocaldb;Database=MarketIdentity;Trusted_Connection=True;MultipleActiveResultSets=true"
}
services.AddDbContext<EfDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MarkIdentity")));
User contributions licensed under CC BY-SA 3.0