This is MVC Identity. Please see attached screenshot.
If this is too complicated, I'll just do this in a stored proc.
I want to get a list of users and their roles. The table structure has changed with MVC Identity. I know I can get the users and roles like this but I want to join them together
var context = new ApplicationDbContext();
var allUsers = context.Users.ToList();
var allRoles = context.Roles.ToList();
I tried joining them together but looks like I need to drill down to RoleId somehow.
This is what I want
from [dbo].[AspNetUsers] u
left join [dbo].[AspNetUserRoles] ur on ur.userId = u.Id
left join [dbo].[AspNetRoles] r on r.id =ur.RoleId
I tried this but this brings back 4 rows. It should be 2. I think the left join is wrong.
var users = (from r in roles
join u in allusers on r.Users.Select(m => m.UserId).ToString() equals u.Roles.Select(m =>m.UserId).ToString()
RoleId = r.Id