user469652
user469652

Reputation: 51211

Entity framework: Need a easy going, clean database migration solution

I'm using entity framework model first development, and I need to do database migration often,

The EF database generation power pack doesn't help a lot, because that data migration never worked here.

The database migration here I mean, change the model, and then I can update the existing database from the model, but creating a new one.

Is there any free of charge tool here invented here yet? Or would this going to be a new feature of next EF release?

PS: I love django's ORM.

Upvotes: 3

Views: 862

Answers (3)

KristoferA
KristoferA

Reputation: 12397

It is not free but has 30-day free trial: here is a tool that address that one (by generating SQL-DDL incremental change scripts), as well as many other shortcomings in the EF4 designer:
http://huagati.com/edmxtools/

Intro video:
http://huagati.blogspot.com/2010/07/introducing-model-comparer-for-entity.html

Upvotes: 0

John Saunders
John Saunders

Reputation: 161773

I use a couple of tools right now for migration, both of EF models and of schemas generated through the NORMA tool. I mostly use the ApexSQL Diff tool, then run the generated scripts through their ApexSQL Edit tool. With the Diff tool, I compare a database created from the model against the "current" database to create a change script. I use the latter because it will break the execution into batches and show the errors on each batch separately (if there are any errors).

On a related note, I've been using the ApexSQL Data Diff tool to script changes in base data like lookup tables.

I've been intrigued by the Data-Tier Applications feature of Visual Studio 2010 and SQL Server 2008 R2. It seems to store the metadata description of the database to be created, so that when you redeploy the DAC package, it compares the metadata for changes. It then changes only the parts of the database that actually need changing. This should allow a single deployment package to be used to upgrade different revision levels of the database, without the need for individual per-version upgrade scripts. I haven't yet used that, though, and I believe it's limited to SQL Server 2008 R2.

Upvotes: 1

Kobi Hari
Kobi Hari

Reputation: 1248

Had the same problem about 4 months ago. We were considering EF and the only issue that we could not resolve was DB migration when using the "code first" approach.

Its easy to create a new DB from code, but what if you already have a DB that was created from the code, and now you add a new property to one of the classes, or worse, change its type or name. I looked for a solution for this problem for quite a while but could not find anything. From the nature of the problem I doubt there will be a solution soon. EF needs to be able to "remember" the code that created the original DB schema, then do an auto "diff" between the original code and the current code, and finally analyze the changes and implement them on the DB schema in a way that will not destroy stored data... It needs to be able to deal with possible refactoring, class renaming, and so on. I doubt this will be a feature anytime soon...

Upvotes: 1

Related Questions