Reputation: 383
Application is of MVC5 Identity based in c#. As observed, AspNetUserRoles
is not populated in EDMX. Certainly cannot query on it using LINQ.
In Data access layer, having the function GetAllUsers()
. For each user need to get its role which is mapped in AspNetUserRoles
table. Able to get all users but not having its role. Hot to get role for each user ?
Upvotes: 2
Views: 1281
Reputation: 4895
AspNetUserRoles
is a mapping table (many-to-many), so it's not generated in EDMX (by design, it does not have primary key
)
You can get roles of user by using navigation properties
:
user.Include(u => u.Roles); // only need if lazy loading disabled
var roles = user.Roles;
Upvotes: 3