我正在使用EF 6的ASP.NET MVC 5的默认模板。 它生成的个人信息模型是
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
我希望能够管理和编辑用户列表,所以我对身份模型进行了脚手架,它在ApplicationDbContext类中添加了以下一行。
public System.Data.Entity.DbSet<QProj.Models.ApplicationUser> ApplicationUsers { get; set; }
我知道这是错的,但我不知道如何解决这个问题。
这些步骤让我成功地构建了ApplicationUser。
DbSet<MyAppUser> MyAppUsers
对于ApplicationDbContext,删除它db.MyAppUsers
到 db.Users
那你就可以了,希望对你有所帮助。