如何从MVC5的新ASP身份表中获取UserId和UserName?

时间:2013-09-28 07:56:05

标签: asp.net-mvc asp.net-mvc-5 asp.net-identity

在我的MVC4应用程序中,我有以下模型:

public partial class UserProfile
{
    public UserProfile()
    {
        this.webpages_Roles = new List<webpages_Roles>();
    }
    public int UserId { get; set; }
    public string UserName { get; set; }
    public virtual ICollection<webpages_Roles> webpages_Roles { get; set; }
}

我在这个类/表中使用了一个带有Entity Framework的select来获取UserId和UserNames的列表。

现在我明白它与MVC5完全不同。

有人可以告诉我如何使用MVC5获取相同的信息吗?是否有可以使用的内置方法?

1 个答案:

答案 0 :(得分:0)

您可以通过EF特定的IdentityDbContext.Users属性枚举1.0 RTM标识位中的所有用户。

在未来的版本(可能是1.1)中,我们也会为UserManager添加一个IQueryable for TUser,因此您不必下拉到特定的商店来枚举用户。