I am trying to get a list of all the roles in my application. I have looked at the following post Getting All Users... and other sources. Here is my code which I think is what I am supposed to do.
var roleStore = new RoleStore<IdentityRole>(context)
var roleMngr = new RoleManager<IdentityRole>(roleStore);
List<string> roles = roleMngr.Roles.ToList();
However, I’m getting the following error: Cannot implicitly convert type GenericList(IdentityRole)
to List(string)
. Any suggestions? I am trying to get the list so I can populate a dropdown list on a registration page to assign a user to a particular role. Using ASPNet 4.5 and identity framework 2 (I think).
PS I’ve also tried the Roles.GetAllRoles method with no success.
roleMngr.Roles.ToListAsync();
and useMicrosoft.EntityFrameworkCore
– Skew