Search code examples
c#.net-coreasp.net-core-mvcasp.net-identity

Net Core Difference between IdentityRole and IdentityUser


In Net Core Identity Management, what is the difference between IdentityRole and IdentityUser?

public class AppIdentityRole : IdentityRole  
 { }  

 public class AppIdentityUser : IdentityUser  
 {  
     public int Age { get; set; }  
 }  


 public class AppIdentityDbContext   
   : IdentityDbContext<AppIdentityUser, AppIdentityRole, string>  
 {  
     public AppIdentityDbContext(DbContextOptions<AppIdentityDbContext> options)  
         : base(options)  
     { }  
 }  

Solution

  • Identity user: Use for authenticate ex : login user

    Identity role : Use for authorization ex: Administrator (above user belongs to administrator role)

    Users have roles, roles have permissions. Like create app

    https://social.technet.microsoft.com/wiki/contents/articles/51333.asp-net-core-2-0-getting-started-with-identity-and-role-management.aspx

    https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.2&tabs=visual-studio