public class UserLogin : IdentityUserLogin<Guid> { } public class UserRole : IdentityUserRole<Guid> { } public class UserClaim : IdentityUserClaim<Guid> { } public class Role : IdentityRole<Guid, UserRole> { } public class User : IdentityUser<Guid, UserLogin, UserRole, UserClaim> { }
public class XYZDbContext : IdentityDbContext<User, Role, Guid, UserLogin, UserRole, UserClaim> { /// <summary> /// 构造函数 /// </summary> public XYZDbContext () : base("XYZDbContext ") { } /// <summary> /// 在模型创建时 /// </summary> /// <param name="modelBuilder">模型构建器</param> protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // 配置实体类型映射到的表名 modelBuilder.Entity<User>().ToTable("User"); modelBuilder.Entity<Role>().ToTable("Role"); modelBuilder.Entity<UserLogin>().ToTable("UserLogin"); modelBuilder.Entity<UserClaim>().ToTable("UserClaim"); modelBuilder.Entity<UserRole>().ToTable("UserRole"); } }