这有没有问题:为什么UserStore和RoleStore之间存在实现差异?
public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{
public ApplicationUserStore(MyAppDb context)
: base(context)
{
}
}
这枚:
public class ApplicationRoleStore : RoleStore<ApplicationRole, string, ApplicationUserRole>
{
public ApplicationRoleStore(MyAppDb context)
: base(context)
{
}
}
...产生以下编译时错误:
The type 'MyApp.Models.ApplicationRole' cannot be used as a type parameter 'TRole' in the generic type or method 'Microsoft.AspNet.Identity.EntityFramework.RoleStore'. There is no implicit reference conversion from 'MyApp.Models.ApplicationRole' to 'Microsoft.AspNet.Identity.EntityFramework.IdentityRole'.
此问题试图解决这个问题来了这里: Why is UserManager.CreateIdentityAsync() looking for IdentityRole and how to fix?
只要我解决这个问题,我并不在乎我解决这个问题。谢谢。