Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Using RoleManager in ASP.NET 5/MVC 6 ?

$
0
0

Hi, 

I want to create a new Role, "Administrator", in my ASP.NET 5/MVC6 project, but I don't know how to register the RoleManager<T> into the Dependency Injection container.

In my controller I've got UserManager<T> working, but when I add RoleManager<T> I get an error saying : 

"InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNet.Identity.RoleManager`1[EmptyProject.Models.ApplicationUser]' while attempting to activate 'EmptyProject.Controllers.AccountController'."

My controller has a constructor that looks like this:

public AccountController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager, RoleManager<ApplicationUser> roleManager)

In my Startup.cs I haven't done any changes.

Can someone explain how to get RoleManager<T> working?


Viewing all articles
Browse latest Browse all 9386

Trending Articles