How do I get the names of the IdentityUser names in the view?
Using an ASP.NET MVC5 user ID, I am trying to display the IdentityUser role names in the view.
It seems that the user Identity has a Roles property that is a set IdentityUserRole
instead of IdentityRole
. The difference IdentityUserRole
is the relationship between IdentityUser
and IdentityRole
, and the IdentityRole
actual model [+] . Apparently there is no navigation between IdentityUser and IdentityRole. So all we get is the RoleId from .Role
IdentityUserRole
- Is there an easy way to get the names of the roles?
- Using the Fluent API, we can define a virtual navigation property between
IdentityRole
andIdentityUserRole
so that we can easily get the name across the whole project? - If it's by design, what's the advantage of not letting us get
IdentityRole
straight?
source to share