未创建身份表

Identity tables not being created

在我的 ConfigureServices 我有:

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

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

Configure 我有:

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

    app.UseIdentity();

    //...
}

当我 dnx . add migration addingIdentity 时,我没有得到在新迁移文件中创建的任何标识表(因此 apply 不执行任何操作)。

缺少什么?

原来是因为我的 DbContext 没有继承自 IdentityDbContext...

public sealed class Context : IdentityDbContext<IdentityUser>