views:

337

answers:

2

I've been playing with Entity Framework 4, using the model driven approach to generate the database script from my entities. This is great but I'm not sure how this works when it comes to versioning the database. I'm guessing if I wanted to use an active record type migration framework I'd have to work the other way around and generate my entities from my database? Is there any way to use the model driven approach and version the database properly?

A: 

Well, if you want to work like ActiveRecord, then you need to work like ActiveRecord. :)

However, if you want to use model-first but still use migrations, this will be possible, but will require extra work on your behalf. Model-first will generate a database change script. You will have to extract the relevant parts into migrations, as well as manually writing undo scripts. Although this involves some manual labor, it doesn't strike me as terribly difficult.

Craig Stuntz
A: 

You can try Wizardby: this is a tool for managing database migrations. It doesn't integrate with EF (since it's nearly impossible to integrate with it in this respect), but does the job.

Anton Gogolev