So it seems that I was looking for Codebased Migrations , which is activated when I set AutomaticMigrationsEnabled = false. My models were created from an existing database. To activate the migration, all I had to do was enable the Enable-Migrations, create a new new migration file using Add-Migration, disable it (my models are already in the database, so I donβt want EF tried and create them) and deploy. To deploy, I added the following to the Global.asax file:
protected void Application_Start() { var config= new Configuration(); var migrator = new DbMigrator(config); migrator.Update(); }
A new __MigrationHistory table was created and a new migration record was created in it. This new migration entry had a hash of my models, so now any changes to my models can be written for me in future migrations with EF.
To test, I created another migration file (Add-Migration), added a new property to the model, launched Add-Migrations, in which a new field was written, and then deployed my application. Migration performed as expected.
enamrik
source share