为什么UserStore和RoleStore之间有实现差异? [英] Why is there an implementation difference between the UserStore and the RoleStore?

查看:153
本文介绍了为什么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)
    {
    }
}

...产生以下编译时错误:

...produces the following compile time error:


类型MyApp.Models.ApplicationRole不能用作通用类型或方法
'Microsoft.AspNet.Identity.EntityFramework.RoleStore'中的
参数'TRole'类型。
没有从'MyApp.Models.ApplicationRole'
到'Microsoft.AspNet.Identity.EntityFramework.IdentityRole'的隐式引用转换。

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'.

这个问题来自于试图解决这个问题:
为什么UserManager.CreateIdentityAsync()寻找IdentityRole和如何解决?

This issue came from trying to solve the issue here: Why is UserManager.CreateIdentityAsync() looking for IdentityRole and how to fix?

只要我解决这个问题,我真的很关心我解决这个问题的方法。谢谢。

I don't really care which way I solve this as long as I solve it. Thanks.

推荐答案

这里没有问题,没有实现差异。一定是打嗝了Visual Studio 2013的重新启动没有解决编译时错误。但是,重新启动计算机。 这里没有问题 - 沿着。

There is no issue here and no implementation difference. It must have been a hiccup. A restart of Visual Studio 2013 did not resolve the compile-time error. However, a restart of the computer did. No issue here--move along.

这篇关于为什么UserStore和RoleStore之间有实现差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆