Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Code-First Migrations Released With Entity Framework 4.3

Code-First Migrations Released With Entity Framework 4.3

Entity Framework 4.3 release finally brings the Migrations feature to Developers, without having to depend on separate pre-release binaries.

What is EF Migrations? If you are using Entity Framework Code-First, Migrations allows you to update your database schema to reflect your POCO classes without having to drop and recreate them. This involves DDL statements to create new tables/columns, alter existing ones, etc. which get generated. The feature has been available to developers for a while as a Nuget package (which can be still used if you are using a lower version of Entity Framework for legacy reasons), but not formally supported by Microsoft.

For a while, this has been one of the most requested features in Entity Framework.

Separate walkthroughs for Automatic Migrations and Code Based migrations are present on the MSDN Team blog. The first one uses features inside Visual Studio along with code-based migration, whereas the second one uses a pure code-only approach. Ideally you only require code based migrations in cases where you want to override default behavior for e.g. renaming columns instead of dropping and creating a new one or providing a default value for the added column.

Migrations also allows you to create deployment scripts to be used against the production database.

Entity Framework is an Object-Relational Mapper provided by Microsoft for .NET applications.

Rate this Article