BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News EF 4.3 Gets Code First Migrations But No Enum Support

EF 4.3 Gets Code First Migrations But No Enum Support

This item in japanese

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. 

Rate this Article

Adoption
Style

BT