当我在数据访问层中为ApplicationUserManager
和ApplicationRoleManager
类创建构造函数时,出现此错误:
There is no argument given that corresponds to the required formal parameter 'optionsAccessor'
of 'UserManager<IdentityUser>.UserManager(IUserStore<IdentityUser>, IOptions<IdentityOptions>,
IPasswordHasher<IdentityUser>, IEnumerable<IUserValidator<IdentityUser>>,
IEnumerable<IPasswordValidator<IdentityUser>>, ILookupNormalizer, IdentityErrorDescriber,
IServiceProvider, ILogger<UserManager<IdentityUser>>)'
There is no argument given that corresponds to the required formal parameter 'roleValidators'
of 'RoleManager<IdentityRole>.RoleManager(IRoleStore<IdentityRole>, IEnumerable<IRoleValidator<IdentityRole>>,
ILookupNormalizer, IdentityErrorDescriber, ILogger<RoleManager<IdentityRole>>)'
我的ApplicationRole
类
public class ApplicationRole : IdentityRole
{
}
我的User
类
public class User : IdentityUser
{
}
我的ApplicationRoleManager
类
public class ApplicationRoleManager : RoleManager<ApplicationRole>
{
public ApplicationRoleManager(RoleStore<ApplicationRole> store)
: base(store)// error here
{
}
}
我的ApplicationUserManager
类
public class ApplicationUserManager : UserManager<User>
{
public ApplicationUserManager(IUserStore<User> store)
: base(store) // error here
{
}
}
(使用ASP.NET Core和AspNetCore.Identity)
看起来您可能会混合和匹配您的技术。