"Out of the box"ApplicationUser 클래스에 ResetPassword라는 새 속성을 추가했지만 "추가 마이그레이션"을 실행하면 자동 생성 된 마이그레이션 클래스의 위/아래 메서드가 비어 있으며 응용 프로그램에 다음 오류가 발생합니다. "ApplicationDbContext '컨텍스트를 지원하는 모델이 데이터베이스를 만들 때 변경되었으므로 코드 처음 마이그레이션을 사용하여 데이터베이스를 업데이트하는 것이 좋습니다". 확장 Identity 계정이 AspNetUsers 테이블로 자동 마이그레이션하지 않는 이유는 무엇입니까?
이
내 코드입니다 :public class ApplicationUser : IdentityUser
{
public bool ResetPassword { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager, string authenticationType)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
// 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();
}
}
월 DAL 클래스는 다음과 같습니다
var에 userManager = 컨텍스트 :
public class DefaultConnection : DbContext
{
public DefaultConnection()
: base("DefaultConnection")
{
this.Configuration.ProxyCreationEnabled = false;
this.Configuration.LazyLoadingEnabled = false;
}
public DbSet<Category> Categories { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<Model> Models { get; set; }
public DbSet<Variable> Variables { get; set; }
public DbSet<Column> Columns { get; set; }
public DbSet<Project> Projects { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Config> Configs { get; set; }
public DbSet<Target> Targets { get; set; }
public DbSet<Organisation> Organisations { get; set; }
public DbSet<OrgGroup> OrgGroups { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
이에 로그인 오류가 발생합니다 라인입니다 .OwinContext.GetUserManager();