BT

EF 4.3 Gets Code First Migrations But No Enum Support

by Roopesh Shenoy on Jan 16, 2012 |

Entity Framework 4.3 Beta has been announced and one of the biggest feature updates is Automatic Database Migrations for Code First. The version also comes with complete XML documentation and improved logging. However, one commonly requested feature, Enum Support, will make it only in EF 5.0.

What exactly is Migrations? As of EF 4.2, if you use Code First with Entity Framework, every time you modify the models, depending on your preferences either the database gets dropped and recreated (in the process losing your test data) or it leaves the database as-is leaving you to upgrade the schema manually. One work-around for this is to create a custom database initializer and seed the data so that it gets added to the Database after it is recreated. With automatic migrations however, all this will become history.

This blog post from Microsoft explains how Migrations can be enabled for your project so that the database upgrades automatically when you modify your model. You can get the SQL script that was used for the upgrade which can be useful later for production deployments. You can also customize these migrations – for e.g. adding a custom default value to a new column getting added.

This version also includes complete XML documentation (which will help with intellisense) and more detailed logs when verbose logging is used.

Some features will not be included in EF 4.3, including the much-awaited Enum Support. This is what the team had to say - 

We’ve been working on a number of features that required updates to some assemblies that are still part of the .NET Framework. These features include enums, spatial data types and some serious performance improvements.

As soon as the next preview of the .NET Framework 4.5 is available we will be shipping EF 5.0 Beta 1, which will include all these new features.

For now the work-around is to either create mini-wrappers for the Enum properties or create new entities, both of which are slightly clunky. Hopefully we will get this feature soon as well.

Note that the beta is not intended or licensed for production use, and you will have to wait for the final release if you want to use it in your commercial projects. You can however use it to checkout the new features and provide feedback to the EF Team. 

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

RIA Services works with only EF 4.1 by Roopesh Shenoy

This is one thing I need to add - if you are using some other bits like RIA services, then you need to see what is the version of EF you can work with (currently supported one is EF 4.1). The semantic versioning of each .NET bit of technology now seems to be independent of the core framework and that tends to confuse things a bit.

Nuget helps though.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT