The information in this post is out of date.
Visit msdn.com/data/ef for the latest information on current and past releases of EF.
For Code First Migrations see http://msdn.com/data/jj591621
Back in April we announced the release of Entity Framework 4.1 (EF 4.1). The most consistent request we have heard from you since releasing EF 4.1 has been for a migrations solution for Code First that will incrementally evolve the database schema as you model changes over time. Today we are announcing the release of our first Community Technical Preview (CTP) of our Code First Migrations work.
This initial CTP is primarily focused on the developer experience inside of Visual Studio. We realize this isn’t the only area in which migrations is important and our team is also working on scenarios including team build, deployment and invoking migrations from outside of Visual Studio as well as from custom code.
You may be wondering why we are releasing the ‘August 2011 CTP’ in July 2011… we were so eager to get the release in your hands we ended up shipping early!
The migrations walkthrough gives an overview of these commands and how to use them for development.
Once installed, a number of additional migrations commands are available in the Package Manager Console inside of Visual Studio.
Prerequisites & Incompatibilities
Important: If you have previously run the EF 4.1 stand alone installer you will need to upgrade or remove the installation before using migrations. This is required because the installer adds the EF 4.1 assembly to the Global Assembly Cache (GAC) causing the original RTM version to be used at runtime rather than Update 1.
This release is incompatible with “Microsoft Data Services, Entity Framework, and SQL Server Tools for Data Framework June 2011 CTP”.
Issues & Limitations
We really wanted to get your feedback early in the release cycle so this CTP hasn’t been polished and isn’t a complete set of the features we intend to ship.
Some known issues, limitations and ‘yet to be implemented’ features include:
Please read this list before using migrations as there are some important limitations of this initial CTP.
- There is no provider model, this release only targets SQL Server, including SQL Azure. SQL Compact and other providers are not supported. We are currently working through what the provider model should look like for migrations.
- All existing tables will be re-built during first migration. The components we are using for schema comparison are overly sensitive to things such as ANSI_PADDING. This often results in tables being rebuilt when you swap to using migrations to maintain the schema. We are working on removing this behavior.
- Extra database constructs, such as indexes, can not be added in custom scripts. If you add an index in a custom script it will be removed by the next automatic upgrade. This is a limitation of this first CTP and we intend to change this behavior.
- Migrations is overly sensitive to column ordering and will re-build a table to insert a column in the correct order. We intend to make this behavior customizable.
- The custom scripts that migrations scaffolds are verbose and include a lot of additional SQL that is not required. We are working to tidy these up so that they only include the core commands.
- Migrations currently needs to run in full trust. This isn’t an issue when working inside of Visual Studio but if consuming the migrations assembly from custom code you may want to run in medium trust. We are looking at ways to support this in a later release.
- This release is only available via NuGet. As we support more scenarios such as team build and an ‘outside of Visual Studio’ command line experience we will also support more installation options.
- There is a known issue that may result in a “The project ‘<project name>’ does not contain or reference any contexts.” error message. This issue occurs when your context is defined in a referenced project and NuGet’s Package Manager Console (PMC) is initialized before your solution is loaded. If you encounter this behavior, close PMC and restart Visual Studio taking care not to reopen PMC until after your solution has loaded.
- The performance of migrations is not ideal in this preview and we are working to improve performance for upcoming releases.
- Previewing changes via the ‘–Script’ option only works after the schema has been upgraded at least once using migrations. If you haven’t used migrations on the database you will just get a create script for the entire database when using ‘-Script’.
- Downgrade is currently not supported. When generating custom scripts you will notice that the script is named ‘Up.sql’ but there is no corresponding ‘Down.sql’. We are planning to add downgrade functionality prior to RTM but it is not available in this release.
This is a preview of features that will be available in future releases and is designed to allow you to provide feedback on the design of these features. It is not intended or licensed for use in production. If you need assistance we have an Entity Framework Pre-Release Forum.
We really want your feedback on this work so please download it, use it and let us know what you like and what you would like to see change. You can provide feedback by commenting on this blog post.
ADO.NET Entity Framework Team