我正在将一个项目从.Net 4.6.2迁移到.Net Core 2.0。在Net Core中,RoleProvider的替代品是什么?
无法找到类型或命名空间名称'RoleProvider'(是否缺少using指令或程序集引用?)
public class CustomerRoleProvider : RoleProvider
{
public override string CustomerName { get; set; }
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
{
新代码是这样的,收到了错误。
Using the generic type 'RoleManager<TRole>' requires 1 type arguments
// Error first line: Using the generic type 'RoleManager<TRole>' requires 1 type arguments
public class CustomerRoleProvider : RoleManager
{
public string ApplicationName { get; set; }
public void CreateRole(IServiceProvider serviceProvider, string roleName)
{
var RoleManager = serviceProvider.GetRequiredService<RoleManager<IdentityRole>>();
throw new NotImplementedException();
}
更新: John Kenney的答案看起来很不错,希望有人能够编辑他的答案并加入更多内容。