我怎样才能改变由asp.net身份3(vnext)中使用的表名? [英] How can I change the table names used by asp.net identity 3 (vnext)?
本文介绍了我怎样才能改变由asp.net身份3(vnext)中使用的表名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在asp.net身份2来改变标识表名的命名方法不asp.net身份3工作。
The method used in asp.net identity 2 to alter the identity table names does not work in asp.net identity 3.
推荐答案
修改建设者实体在ApplicationDbContext的OnModelCreating,采用ForSqlServerToTable扩展方法来改变所需表格(S)的名称。
Modify the builder entities in OnModelCreating of your ApplicationDbContext, using ForSqlServerToTable extension method to change the desired table(s) name.
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
builder.Entity<ApplicationUser>().ForSqlServerToTable("Users");
builder.Entity<IdentityUserRole<string>>().ForSqlServerToTable("UserRoles");
builder.Entity<IdentityUserLogin<string>>().ForSqlServerToTable("UserLogins");
builder.Entity<IdentityUserClaim<string>>().ForSqlServerToTable("UserClaims");
builder.Entity<IdentityRole>().ForSqlServerToTable("Roles");
}
}
这篇关于我怎样才能改变由asp.net身份3(vnext)中使用的表名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文