c# - 未创建身份表

标签 c# asp.net entity-framework ef-code-first asp.net-core

在我的 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 时。添加迁移 addingIdentity,我没有在新迁移文件中创建任何身份表(因此 apply 不执行任何操作)。

缺少什么?

最佳答案

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

public sealed class Context : IdentityDbContext<IdentityUser>

关于c# - 未创建身份表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32013427/

相关文章:

C#:循环编码

javascript - RadWindow 未在客户端上打开

entity-framework - EF5 Code First - 数据注释与 Fluent API

entity-framework - 多个表中的一对一映射

c# - 无法调用类的方法c#

c# - 如何将光标移动到datagridview中的下一行

c# - 您如何正确使用 UpdatePanel?

c# - Entity Framework Code First 关联/FK 问题和假设/默认值

c# - 将 vb.net 代码片段转换为 C#

c# - 复选框!指定的转换无效