Я использую шаблон по умолчанию для ASP.NET MVC 5 с EF 6. Она формирует модель идентичности какЛеса строительные ApplicationUser
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', или наследовать от' IdentityUser'? –
@BrendanGreen Как видно из приведенного выше кода, ApplicationUser наследуется от IdentityUser. – lhhc
Итак, как вы «помогли» ApplicationUser? Поскольку ваш контекст наследуется от IdentityDbContext, вам не нужно использовать dbset, определенный в вашем классе. –