這有沒有問題:爲什麼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?
只要我解決這個問題,我並不在乎我解決這個問題。謝謝。