4
Hello!
In my first job, I worked using code-first with Entity Framework 4. At this time, I noticed a limitation in it: the generated Migrations only ran in order. For example, if in my branch two people are working with persistence, it can happen that generated Migrations are not executed. This was due to an Migration with minor timestamp the last registered in the bank not be executed.
A little later, I left the company and from there I worked only with Nhibernate and Migrations using Migsharp. However, for the sake of organization and practicality I always preferred the Entity and I was thinking about the possibility of implementing it in new projects of the company. The issue of this requirement to run Migrations in order would not work here: If the master branch suffers a last-minute persistence correction to solve problems already in production, the development branch would have to change all the timestamp of the already created Migrations that are not yet in master, or the Migrations would not be executed.
As I commented, I had this problem in Entity Framework 4. My question is: In the new versions of Entity Framework is there any configuration that allows the execution of Migrations without a mandatory order? If not, what’s the most 'professional' way to prevent problems like this from occurring during job development along with last-minute fixes, or even continuous integration processes when pushing?
Thank you!
Thank you for your answer, Gypsy. One more question: If Migrations are already in production, the reversal of Migration could cause data loss. And the branch that is already in production, where emergency corrections also occur, has Migrations already executed in production and with higher timestamp than Migrations not executed in development branch production. This has already happened because the bug was so critical that it could not wait for the development of new features to go up the fix. In this case, how to run the dev Migrations in Prod?
– Striter Alfa
You could only reverse Migrations which have not yet been carried out in production. If any Migration was done improperly executed, you will have to create another Migration to reverse this Migration that was wrong.
– Leonel Sanches da Silva