C# 未创建标识表
在我的C# 未创建标识表,c#,asp.net,entity-framework,ef-code-first,asp.net-core,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:DefaultConnec
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();
//...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
//...
app.UseIdentity();
//...
}
当我dnx时。添加迁移addingIdentity
,我没有在新迁移文件中创建任何标识表(因此,apply
不起任何作用)
缺少什么?原来是因为我的DbContext没有从IdentityDbContext继承
public sealed class Context : IdentityDbContext<IdentityUser>
公共密封类上下文:IdentityDbContext
嗯,没有-因为migrations文件夹中新的addingIdentity
文件是空的-在Up
或Down
方法中没有任何内容。所以它不会有任何效果。