Can't create migration in asp.net core 2.0

0

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>();
    }
c#
database-migration
asp.net-core-2.0
sqlclient
ef-core-2.0
asked on Stack Overflow Oct 28, 2017 by Александр Калашников • edited Feb 1, 2018 by Nkosi

1 Answer

0

try this

"ConnectionStrings": {
    "MarkIdentity": "Server=(localdb)\\mssqllocaldb;Database=MarketIdentity;Trusted_Connection=True;MultipleActiveResultSets=true"
}

services.AddDbContext<EfDbContext>(options =>
    options.UseSqlServer(Configuration.GetConnectionString("MarkIdentity")));
answered on Stack Overflow May 4, 2018 by saeef ahmed • edited May 4, 2018 by sɐunıɔןɐqɐp

User contributions licensed under CC BY-SA 3.0