How to turn off Entity Framework CF Migrations for an environment

asp.net-mvc-5 ef-migrations entity-framework-6

Question

Is it possible to turn off Entity Framework using the web.config? In the application I'm developing we have the following environments

  • Development
  • Continuous Integration
  • Integration Testing
  • Production

The Integration Testing and Production databases are managed by a database administrator, so we have to send them a script to make changes to the database.

I've spent hours Googling and looking through old projects, and I can't find how to do this or remember if we ever turned off migrations on the old projects in the first place.

From the lack of information I'm doubting if what I'm asking is needed or possible, but there is something in the back of my head that's annoying me about this so I thought I'd ask the experts.

1
1
2/24/2015 3:49:55 PM

Accepted Answer

The easiest method is to simply delete the dbo._MigrationHistory table from these environments. If that table doesn't exist, then only an "initial" migration can ever be generated against that database, which will fail if someone tries to actually apply it to a database with existing tables.

2
2/24/2015 3:46:27 PM

Popular Answer

You could set the database initializer in the config file as described at the bottom here, so you can have an updating initializer in the environments you want



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow