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?
I’ve been playing with Entity Framework 4, using the model driven approach to generate
Share
This will be coming soon as a NuGet package called EntityFramework.Migrations
A demo was performed by Scott Hanselman at TechEd 2011 (available online at http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV349). The relevant section is 45 minutes in.
In short, once the package is installed, you’ll enter the following into the Package Manager Console to generate a database change script:
UPDATE (13-Nov-2011)
The alpha 3 build of this package is now available on NuGet. Rather than use the cmdlet
migrate -scriptmentioned above, it uses the cmdletAdd-Migration <migrationname>. A walk-through of its use can be found on the ADO.NET team blog.UPDATE (14-Feb-2012)
This functionality is now available as part of the main EntityFramework NuGet package, starting with version 4.3. An updated walk-through using EF 4.3 can be found on the ADO.NET team blog.