【发布时间】:2016-06-21 21:24:58
【问题描述】:
我刚刚使用 UserStore 定义了一个实例,如下所示。
var store = new UserStore<ApplicationUser>(new ProjectEntities());
但出现以下错误
类型“project_name.Models.ApplicationUser”不能用作类型 泛型类型或方法“UserStore”中的参数“TUser”。 没有隐式引用转换 'project_name.Models.ApplicationUser' 到 'Microsoft.AspNet.Identity.EntityFramework.IdentityUser'。
这里是我如何在IdentityModel.cs 中定义ApplicationUser
public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{
public ApplicationUser()
{
this.Id = Guid.NewGuid().ToString();
}
// custom User properties/code here
public string Full_Name { get; set; }
public string Gender { get; set; }
public async Task<ClaimsIdentity>GenerateUserIdentityAsync(ApplicationUserManager manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
}
【问题讨论】:
标签: c# asp.net-mvc entity-framework asp.net-mvc-3 asp.net-identity