Thoughts on ASP.NET MVC3 Update and Entity Framework 4.1

Microsoft have now released an update to ASP.NET MVC3 imaginatively called “ASP.NET MVC3 Update”. This update upgrades NuGet, bundles Entity Framework 4.1 with all new templates, adds HTML5 template support and splits the jQuery libraries off into NuGet packages so they can be upgraded individually.

The bundling with new MVC projects is a sign that Microsoft has selected Entity Framework as the “chosen” ORM layer from now on. Linq2SQL is not flexible enough when dealing with pre-existing database schemas and third party solutions such NHibernate are difficult to get pointy-haired boss approval. EF 4.1 adds “code first” support where you define a very simple CLR object and it will automatically create the database tables for you. At first your eyes will light up thinking “finally! Rails’ ActiveRecord for .NET! Blessed by Microsoft!” until you find several missing pieces:

  • No migration support. The only option that EF provides when the “code first” objects behind your schema change (for instance, you add a new property) is to drop the entire database and start again. Rails has had this for years.
  • No code first support on real databases. That’s right, code first only works on SQL Compact file-based databases. This is fine for development but you can forget about just dropping the files onto a clients webserver and have it create your database for you.

There are a couple of ways around the limitations. I am having great success with a combination of MigratorDotNet and Entity Framework to provide an ActiveRecord style schema migration path. Hopefully I can write about this soon.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>