0

I have a model which holds information about a user of this application

public class ApplicationUser : IdentityUser
{
    public string Name { get; set; }
    public string Payroll { get; set; }
}

I have a view model which should show some information about the a user and their role

public class VM_UserAdmin
{
    public string Name { get; set; }
    public string Payroll { get; set; }
    public string Email { get; set; }
    public string Role { get; set; }
}

I can get the name, payroll, email as properties of ApplicationUser no problems with this:

return await _applicationDbContext.Users.ToListAsync();

where _applicationDbContext is my database context.

Can anyone tell me how to reach Roles so I can include this in my VM_UserAdmin model. User.Roles... is no longer available to me in asp.net core 2.1. I have a 1-to-1 relationship of User and Role.

Thanks.

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
dstewart101
  • 1,084
  • 1
  • 16
  • 38
  • "I have a 1-to-1 relationship of User and Role" - How? Identity models a M2M between users and roles, and Identity's functionality depends on this type of relationship. – Chris Pratt Nov 02 '18 at 16:00
  • @chris - sorry, what i meant was in this particular application, a user will only have one role, but that will be managed as a business process – dstewart101 Nov 05 '18 at 09:07
  • 1
    @KirkLarkin - agreed. i got what i needed in that post. thanks. – dstewart101 Nov 05 '18 at 10:55

0 Answers0