Code-base Migration vs. Automatic Migration

ef-migrations entity-framework


I've read these two posts from the team blog as I learn about EF4.3 Migration:

However, even after reading these two papers, I'm still unsure on how they vary and whether to employ code-based migration vs automated migration. Anyone who can help me?


5/30/2012 9:04:43 AM

Accepted Answer

If you don't grasp the difference, it's because you weren't paying attention when reading those articles and presumably didn't follow up with the text's code examples.

Just a magical tool, automatic migration. When you launch your application, you will always have the most recent version of your database since EF performs implicit migrations whenever they are required. In the purest form, you never need to do anything other than enable automatic migrations.

Sometimes automatic migrations are insufficient. To change data, for instance, you need to make some customisation to the migration code or perform some more SQL operations. You do this by invoking the explicit code-based migration method.Add-Migration Explicit migration displays all migration code that will be performed during the migration (there is no additional magic).

In order to specify the database upgrading process in clearly specified explicit phases if automated migrations are disabled, you must always declare explicit migration. When you need to utilize both downgrading and upgrading to a certain version, this is extremely helpful.

5/30/2012 9:04:34 AM

Related Questions


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