【发布时间】:2021-06-11 05:37:06
【问题描述】:
我在管理控制器中面临无法解决类型“Microsoft.AspNetCore.Identity.RoleManager”的服务问题 这是我在管理控制器中注入 RoleManager 的方式
private readonly RoleManager<IdentityRole> roleManager;
private readonly UserManager<ApplicationUser> userManager;
public AdministrationController(RoleManager<IdentityRole> roleManager,UserManager<ApplicationUser> userManager)
{
this.roleManager = roleManager;
this.userManager = userManager;
}
在我的 startup.cs 文件中,我添加了这样的身份服务
services.AddIdentity<ApplicationUser, IdentityRole<int>>()
.AddEntityFrameworkStores<CISContext>()
.AddDefaultTokenProviders();
正如您在我的 startup.cs 文件中添加身份服务时看到的那样,我在 IdentityRole 类中添加了数据类型,以便将 AspNetUsers Id 列的数据类型从字符串更改为 int
请问我该如何解决这个问题?
【问题讨论】:
标签: asp.net-core asp.net-core-identity