jeudi 29 janvier 2015

Entity Framework Migrations with Multiple Branches


Vote count:

0




We have two branches: Trunk and V2.


When fixing a bug in Trunk (new migration), we need to merge it to V2, but V2 is now far behind as it has new migrations and the model doesn't match.


Rowan Miller explains in this video that it is possible to fix this problem by applying an empty migration generated with -IgnoreChanges, but for some reason that doesn't work in my case as I get this error:



"Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration."



Our app has multiple contexts, this is the code that we run on the app_start for each context:



private static void RunMigrations<TContext, TConfiguration>()
where TContext : DbContext, new()
where TConfiguration : DbMigrationsConfiguration<TContext>, new()
{
var initializer = new MigrateDatabaseToLatestVersion<TContext, TConfiguration>();
Database.SetInitializer(initializer);
using (var context = new TContext())
{
context.Database.Initialize(force: true);
context.SaveChanges();
}
}


Am I missing something?



asked 3 mins ago







Entity Framework Migrations with Multiple Branches

Aucun commentaire:

Enregistrer un commentaire