asp.net-mvc – 为什么UserManager.CreateIdentityAsync()正在寻找IdentityRole以及如何修复?

我正在使用Identity2.0和MVC5 CodeFirst我已经扩展了IdentityUser和IdentityRole,如下所示:
public class ApplicationUser : IdentityUser
{
    [required]
    [StringLength(50)]
    public string FirstName { get; set; }

    [required]
    [StringLength(50)]
    public string LastName { get; set; }
}

public class ApplicationRole : IdentityRole
{
    [required]
    [StringLength(50)]
    public string ProperName { get; set; }

    [required]
    public string Description { get; set; }
}

public class MyAppDb : IdentityDbContext<ApplicationUser,ApplicationRole,string,IdentityUserLogin,IdentityUserRole,IdentityUserClaim>
{
    public MyAppDb()
        : base("MyAppDb")
    {
    }
}

注意MyAppDb继承自IdentityDbContext但我传递的是ApplicationRole而不是IdentityRole.我的ApplicationRole继承自IdentityRole,所以这应该不是问题.

但…

我的AccountController抛出了这个错误

The entity type IdentityRole is not part of the model for the current context.

在此代码中的UserManager.CreateIdentityAsync(…):

private async Task SignInAsync(ApplicationUser user,bool isPersistent)
{
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = await UserManager.CreateIdentityAsync(user,DefaultAuthenticationTypes.ApplicationCookie);
     AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent },identity);
}

用户在这里创建:

var user = await UserManager.FindAsync(model.UserName,model.Password);
        if (user != null)
        {
            await SignInAsync(user,model.RememberMe);
            return RedirectToLocal(returnUrl);
        }

什么是“重大故障”?

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....