Reputation: 13
Bellow my MVC5 App IdentityModeld.cs:
public class ApplicationUser : IdentityUser {
public int StaffId { get; set; }
}
//public class ApplicationDbContext :
//IdentityDbContext<User, UserClaim, UserSecret, UserLogin, Role, UserRole> {
//original: http://www.briankeating.net/?tag=/IdentityDbContext
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> {
public ApplicationDbContext() : base("DefaultConnection") {
//Database.SetInitializer<ApplicationDbContext>(null);
//Configuration.AutoDetectChangesEnabled = false;
}
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
//modelBuilder.Ignore<Staff>();
//base.OnModelCreating(modelBuilder);
}
// dublicate from another DbContext
//public DbSet<Staff> Person { get; set; }
}
Commented lines cause error:
The model backing the 'ApplicationDbContext' context has changed since the database was created...
I don't need migrations. There are no changes in my database or models. Can I add to existing ApplicationDbContext existing table from database as is? There is no __MigrationHistory table in my database.
Upvotes: 1
Views: 726
Reputation: 23103
You need to update the shema stored "inside EF" to the current one by adding an empty migration.
Execute the following in the Package Manager Console:
Add-Migration Initial -IgnoreChanges
This should create a new migration with the updated shema for EF, but an empty Up
and Down
method.
Upvotes: 0