Schema Migration a la Rails Migrations
Database change management is a huge headache without the right tools, and the Microsoft stack doesn't have a good answer for this right now.
Database projects were a valiant attempt, but diff-ing a live database with a set of text files is a clunky approach.
Migrations have been used successfully on other platforms (notably, Ruby on Rails) to achieve iterative database change management. Several open-source projects on the .NET platform have even been started, but none have really gained traction.
A migration solution from Microsoft with good tool integration would go along way to making database change management on the Microsoft platform easier.
EF Code First Migrations has shipped as part of the EF 4.3 release. You can add new ideas for improvements to Migrations now. For more information: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx
9 comments
-
AdminDiego Vega
(Admin, DataFx)
commented
Hello Moby,
Some of the same ideas might apply but I think the mechanics would need to be different. Could you please try to flesh out what you have in mind in a separate idea? That way others can vote for it and add comments, and we can track it more accurately.
-
Moby Disk
commented
Everyone is talking code-first when the same ideas should apply to model-first as well. Does anyone use model-first or is that a dead-end now?
-
Alessandro Baroni
commented
A must for code first development
-
HiredMind
commented
Just FYI - I'm using Migrator.NET - works great, although I did need to add some convenience extensions to customize it for my tastes. (I'm not associated with the project, just a happy user)
-
Dorian
commented
Migrations are crutial for us. Currently we use Mig#. It's open source. Right now we use Codefirst, and in the DBinitializer we check if the schema is up to date and if it's not then we call MigSharp.Migrator.Update. It would be good if this kind of thing could be combined into EF - out of the box!
-
Sean Kelly
commented
Auto-Magic Migration (CodeFirst or not) is a WONDERFUL way to sync development changes with a production database. Especially for light-weight development teams/projects.
We are adding a property/field. Do it.
We are adding a related class/table. Do it.
Having the more sophisticated custom "scripts" that include data manipulation (with order of operations) is wonderful too--please don't throw out the Auto-Magic Baby with the Technical Bath Water.
-
Moby Disk
commented
If you are using model-first, you can download the "Entity Designer Database Generation Power Pack" and use a "Sync Database project"
-
danvanderboom
commented
Schema versioning is one of the most difficult challenges of maintaining a mature application. Good tool support would go a long way to reducing the risk involved in making schema changes.
-
Dave
commented
Agreed. Especially with code-first development autogenerating schemas, to then go and and manually create SQL to migrate from one autogenerated schema to another for application upgrades is a monster pain.