Мне нужно создать операции CRUD для РОЛИ.
Я получаю следующую ошибку:
«Невозможно разрешить службу для типа 'Microsoft.AspNetCore.Identity.RoleManager`»
Итак, как я могу ввести roleManager?
Я использую asp net core 2.0 + identity 2.2.1
Класс ApplicationUser
public class ApplicationUser : IdentityUser
{
[Key]
public override string Id { get; set; }
public bool Type { get; set; }
}
Теперь в Startup.cs
services.AddIdentity<ApplicationUser, IdentityRole<int>>()
.AddUserStore<UserStore<ApplicationUser, IdentityRole<int>, ApplicationDbContext, int>>()
.AddRoleStore<RoleStore<IdentityRole<int>, ApplicationDbContext, int>>()
.AddDefaultTokenProviders();
Контроллер
private readonly UserManager<ApplicationUser> _userManager;
private readonly RoleManager<IdentityUser> _roleManager;
public RolesController(UserManager<ApplicationUser> userManager, RoleManager<IdentityUser> roleManager)
{
_userManager = userManager;
_roleManager = roleManager;
}
public IActionResult Index()
{
return View(_roleManager.Roles);
}
Итак, я получаю сообщение об ошибке: «Невозможно разрешить службу для типа Microsoft.AspNetCore.Identity.RoleManager».