Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i
C#
 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&lt;ApplicationUser&gt;().ToTable(&quot;tblUser&quot;).Property(x =&gt; x.Id).HasColumnName(&quot;UserID&quot;);
           modelBuilder.Entity&lt;ApplicationRole&gt;().ToTable(&quot;tblRoles&quot;).Property(x =&gt; x.Id).HasColumnName(&quot;RoleID&quot;);
           modelBuilder.Entity&lt;IdentityUserRole&gt;().ToTable(&quot;tblUserRole&quot;).Property(x =&gt; x.RoleId).HasColumnName(&quot;RoleID&quot;);
           modelBuilder.Entity&lt;IdentityUserRole&gt;().ToTable(&quot;tblUserRole&quot;).Property(x =&gt; x.UserId).HasColumnName(&quot;UserID&quot;);
           modelBuilder.Entity&lt;IdentityUserClaim&gt;().ToTable(&quot;tblUserClaim&quot;).Property(x =&gt; x.Id).HasColumnName(&quot;ClaimID&quot;);
           modelBuilder.Entity&lt;IdentityUserLogin&gt;().ToTable(&quot;tblUserLogin&quot;);


       }
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");

}
Posted
Updated 4-Aug-16 6:18am
v2

1 solution

Well I'll risk taking a beating here for my anwser.

To the best of my knowledge, the ASP Identity is a canned solution written by Microsoft to provide you with a secure way to store identity information. It includes all the components needed in App_Start to program the parameters, models and controllers with views that works 100% after configuration. It has everything under the hood.

Sure you can tweak it, but in order to tweak or change it you will have to reverse engineer how it works, so you can understand how to change it. With that being said, I tried to do the same thing about 7 months ago and spent about 2 days working on it.

I finally realized that the key areas in which I wanted to change were compiled in the DLL for ASP Identity, and without the source, I could not finish my modifications. I did make it past your point that your question reflects.

So I ended scrubbing the idea and started from scratch creating a new identity program that was tailored to my needs. I used the reverse engineering knowledge that I gained as the foundation of my project, then stripped out the ASP Identity from my project.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900