i
create asp.net identity application in this application i used custom class Name Called ApplicationRole and That class is inherited with IdentityRole
public class ApplicationRole:IdentityRole
{
public ApplicationRole():base() { }
public bool IsSuperAdmin { get; set; }
}
and then i used this class on the <pre lang="C#">OnModelCreating Method</pre>
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().ToTable("tblUser").Property(x => x.Id).HasColumnName("UserID");
modelBuilder.Entity<ApplicationRole>().ToTable("tblRoles").Property(x => x.Id).HasColumnName("RoleID");
modelBuilder.Entity<IdentityUserRole>().ToTable("tblUserRole").Property(x => x.RoleId).HasColumnName("RoleID");
modelBuilder.Entity<IdentityUserRole>().ToTable("tblUserRole").Property(x => x.UserId).HasColumnName("UserID");
modelBuilder.Entity<IdentityUserClaim>().ToTable("tblUserClaim").Property(x => x.Id).HasColumnName("ClaimID");
modelBuilder.Entity<IdentityUserLogin>().ToTable("tblUserLogin");
}
after this i used Add-migrations and then update-DataBase
now i opened sql Server it will create aspnetRole table extra
What I have tried:
public class ApplicationRole : IdentityRole
{
public ApplicationRole() : base() { }
public virtual Office OfficeID { get; set; }
public bool IsSuperAdmin { get; set; }
}
public class Office
{
[Key]
public long OfficeID { get; set; }
public string OfficeName { get; set; }
public virtual ICollection<applicationuser> User { get; set; }
public virtual ICollection<applicationrole> Role { get; set; }
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().ToTable("User").Property(x => x.Id).HasColumnName("UserID");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole");
modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims").Property(x => x.Id).HasColumnName("ClaimID");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin");
modelBuilder.Entity<ApplicationRole>().ToTable("Roles").Property(x => x.Id).HasColumnName("RoleID");
}