我正在实现Identity,并且想要自定义表名。我已经成功定制了除“ AspNetUsers”以外的所有表。
代码:
builder.Entity<UserProfile>(opt => opt.ToTable("IdentityUserProfile"));
builder.Entity<User>(opt => opt.ToTable("IdentityUser"));
builder.Entity<IdentityRole<int>>(opt => opt.ToTable("IdentityRole"));
builder.Entity<IdentityUserRole<int>>(opt => opt.ToTable("IdentityUserRole"));
builder.Entity<IdentityUserClaim<int>>(opt => opt.ToTable("IdentityUserClaim"));
builder.Entity<UserProfileLogin>(opt => opt.ToTable("IdentityUserProfileLogin"));
builder.Entity<IdentityUserToken<int>>(opt => opt.ToTable("IdentityUserToken"));
builder.Entity<IdentityRoleClaim<int>>(opt => opt.ToTable("IdentityRoleClaim"));
类型 UserProfile 继承了 IdentityUser ,所以我想将AspNetUsers重命名为IdentityUserProfile
任何建议?
答案 0 :(得分:1)
您可以按照已尝试的方式进行操作,例如:
builder.Entity<IdentityUser>(b =>
{
b.ToTable("IdentityUserProfile");
});
这将重命名由基本类型IdentityUser
实现的表