Sean
Sean

Reputation: 15144

Identity tables not being created

In my ConfigureServices I have:

public void ConfigureServices(IServiceCollection services)
{
    services.AddEntityFramework()
        .AddSqlServer()
        .AddDbContext<Context>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

    services.AddIdentity<User, IdentityRole>()
            .AddEntityFrameworkStores<Context>()
            .AddDefaultTokenProviders();
    //...
}

And in Configure I have:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    //...

    app.UseIdentity();

    //...
}

When I dnx . add migration addingIdentity, I don't get any of the identity tables created in the new migrations file (so the apply doesn't do anything).

What's missing?

Upvotes: 2

Views: 1398

Answers (1)

Sean
Sean

Reputation: 15144

Turns out it was because my DbContext wasn't inheriting from IdentityDbContext...

public sealed class Context : IdentityDbContext<IdentityUser>

Upvotes: 1

Related Questions