My Application Role class
public class ApplicationRole : IdentityRole
{
public string Description { get; set; }
public DateTime RegisterDate { get; set; }
public ApplicationRole()
{
}
public ApplicationRole(string roleName) : base(roleName) { }
public ApplicationRole(string roleName, string roleDescription) : base(roleName)
{
Description = roleDescription;
}
}
我的应用程序角色管理器类
public class ApplicationRoleManager : RoleManager<ApplicationRole>
{
public ApplicationRoleManager(ApplicationRoleStore roleStore,
IEnumerable<IRoleValidator<ApplicationRole>> roleValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
ILogger<ApplicationRoleManager> logger) :
base(roleStore , roleValidators, keyNormalizer, errors, logger)
{
}
}
我的应用程序角色存储类
public class ApplicationRoleStore : RoleStore<ApplicationRole, ApplicationDbContext>
{
public ApplicationRoleStore(ApplicationDbContext dbContext,
IdentityErrorDescriber identityErrorDescriber) :
base(dbContext, identityErrorDescriber)
{
}
}
和应用程序数据库上下文
public class ApplicationDbContext : IdentityDbContext
{
private readonly IConfiguration _configuration;
private readonly IHttpContextAccessor _httpContextAccessor;
public ApplicationDbContext(DbContextOptions dbContextOptions, IHttpContextAccessor httpContextAccessor,IConfiguration configuration)
: base(dbContextOptions)
{
_configuration = configuration;
_httpContextAccessor = httpContextAccessor;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
当我写这个给我一个错误时:
private readonly ApplicationRoleManager<ApplicationRole> _roleManager;
类应用程序角色管理器剂量没有类型参数
我不明白我的错在哪里。
实际上,类ApplicationRoleManager
没有类型参数。
改变:
private readonly ApplicationRoleManager<ApplicationRole> _roleManager;
自:
private readonly ApplicationRoleManager _roleManager;
有关类型参数的更多信息,请参阅此处。