entity framework - EF Code First - Multiple Application Versions Sharing A Database -
we have application developed using code first in ef6. running quite happily on our live infrastructure.
i have made changes required schema alterations , i've generated appropriate migrations.
since application deployed our release process live environment has changed , applications deployed prelive area can validate interaction other applications/services , run tests before application files released live location.
the problem migrations alter database schema when application run in prelive , live version of application choke on model compatibility check.
how have other people approached issue?
is there way of safely running multiple versions of code first application against same database?
if can disable model checking, migrations still run when application first starts or have go generating sql change scripts , running them manually?
i faced same problem. nick disabled migration in dbcontext , created different project database migration. added below check in migratorcode upgrades , never downgrades instead of calling migrator.update() directly.
migrationconfiguration.targetdatabase = new dbconnectioninfo(migrationcontext.environmentsettings.connectionstring, "system.data.sqlclient"); var migrator = new dbmigrator(migrationconfiguration); var localmigrations = migrator.getlocalmigrations(); var dbmigrations = migrator.getdatabasemigrations(); if (localmigrations.except(dbmigrations).any()) { migrator.update(); }
Comments
Post a Comment