EF6 Beta 1 Available
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.
Since releasing Alpha 3 a few months ago, we've been working hard to add the remaining new features to the EF6 runtime and get the EF tooling ready to preview. Today we are pleased to announce the availability of EF6 Beta 1.
We Want Your Feedback
You can help us make EF6 a great release by providing feedback and suggestions. You can provide feedback by commenting on this post, commenting on the feature specifications linked below or starting a discussion on our CodePlex site.
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. The APIs and functionality included in Beta 1 are likely to change as we polish the product ready for the final release of EF6.
If you need assistance using the new features, please post questions on Stack Overflow using the entity-framework tag.
Getting Started with Beta 1
The runtime is available on NuGet. If you are using Code First then there is no need to install the tooling. Follow the instructions on our Get It page for installing the latest pre-release version of Entity Framework.
The tooling is available on the Microsoft Download Center and will work with Visual Studio 2012. Install the tooling if you want to use Model First or Database First.
Note: In some cases you may need to update your EF5 code to work with EF6, see Updating Applications to use EF6.
Things You Need to Know
EF6 Alpha 1-3 Migrations Must Be Recreated
Migrations created with earlier previews of EF6 will need to be recreated dueto some changes we made to the metadata stored in code behind. We realize that changes like this can be frustrating. One of the reasons we release early previews is to get your feedback and bug reports to help us make the final release great. Sometimes that means we need to make breaking changes between preview releases.
To recreate migrations, downgrade to the last migration created with EF5 or earlier, delete migrations from your Migrations folder that were created with EF6, then use Add-Migration to re-scaffold the changes you have made. If migrations are not re-created you will receive the following error when trying to add or apply migrations:
System.Data.Entity.Core.MappingException: Schema specified is not valid. Errors:
<File Unknown>(0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.
Uninstalling Beta 1 Tooling
When you install the Beta 1 tooling it will replace the EF Designer that was included in Visual Studio 2012. To revert back to the tooling that was included with Visual Studio 2012 follow these steps.
- Using Add/Remove Programs, uninstall Entity Framework Tools for Visual Studio 2012
- Repair your Visual Studio 2012 install
What's Changed Since Alpha 3
The following features and changes have been implemented since Alpha 3:
- The EF tooling is included in this preview for the first time for the EF6 release. Our focus with the tooling has been on enabling EF6 support and enabling us to easily ship out-of-band between releases of Visual Studio. The tooling does not included any new features.
- Code First Migrations now supports generating and altering stored procedures. The ability to map to stored procedures was introduced in Alpha 3.
- Entity and complex types can now be nested inside classes.
- DbSet.AddRange & RemoveRange provide a simple and efficient way to add or remove multiple entities.
What Else is New in EF6
The following features and changes were included in earlier previews of EF6.
- Async Query and Save adds support for the task-based asynchronous patterns that were introduced in .NET 4.5. We've created a walkthrough and a feature specification for this feature.
- Custom Code First Conventions allow write your own conventions to help avoid repetitive configuration. We provide a simple API for lightweight conventions as well as some more complex building blocks to allow you to author more complicated conventions. We’ve created a walkthough and a feature specification for this feature.
- Code First Mapping to Insert/Update/Delete Stored Procedures is now supported. We’ve created a feature specification for this feature.
- Connection Resiliency enables automatic recovery from transient connection failures. The feature specification shows how to enable this feature and how to create your own retry policies.
- Dependency Resolution introduces support for the Service Locator pattern and we've factored out some pieces of functionality that can be replaced with custom implementations. We’ve created a feature specification and a list of services that can be injected.
- Code-Based Configuration gives you the option of performing configuration – that was traditionally performed in a config file – in code. We've created an overview with some examples and a feature specification.
- Configurable Migrations History Table allows you to customize the definition of the migrations history table. This is particularly useful for database providers that require the appropriate data types etc. to be specified for the Migrations History table to work correctly. We’ve created a feature specification for this feature.
- Multiple Contexts per Database removes the previous limitation of one Code First model per database when using Migrations or when Code First automatically created the database for you. We’ve created a feature specification for this feature.
- DbModelBuilder.HasDefaultSchema is a new Code First API that allows the default database schema for a Code First model to be configured in one place. Previously the Code First default schema was hard-coded to "dbo" and the only way to configure the schema to which a table belonged was via the ToTable API.
- Enums, Spatial and Better Performance on .NET 4.0 - By moving the core components that used to be in the .NET Framework into the EF NuGet package we are now able to offer enum support, spatial data types and the performance improvements from EF5 on .NET 4.0.
- DbContext can now be created with a DbConnection that is already opened which enables scenarios where it would be helpful if the connection could be open when creating the context (such as sharing a connection between components where you can not guarantee the state of the connection).
- Default transaction isolation level is changed to READ_COMMITTED_SNAPSHOT for databases created using Code First, potentially allowing for more scalability and fewer deadlocks.
- DbContext.Database.UseTransaction and DbContext.Database.BeginTransaction are new APIs that enable scenarios where you need to manage your own transactions.
- Improved performance of Enumerable.Contains in LINQ queries.
- Significantly improved warm up time (view generation) – especially for large models – as the result of a contribution from AlirezaHaghshenas.
- DbModelBuilder.Configurations.AddFromAssembly method was contributed by UnaiZorrilla. If you are using configuration classes with the Code First Fluent API, this method allows you to easily add all configuration classes defined in an assembly.
- Custom Migrations Operations were enabled by a contribution from iceclow and this blog post provides an example of using this new feature.
- Pluggable Pluralization & Singularization Service was contributed by UnaiZorrilla.
- Improved Transaction Support updates the Entity Framework to provide support for a transaction external to the framework as well as improved ways of creating a transaction within the Framework. See this feature specification for details.
What's after Beta 1
Beta 1 contains all the features we are planning to implement for the EF6 release. We'll now be focusing on polishing and completing these features, fixing bugs and everything else to make EF6 a great release. We’ll still consider pull requests for the EF6 release but larger changes or ones that need significant testing will likely be moved to the following release.
If you want to try out changes we've made since the last official pre-release, you can use the latest signed nightly build. You can also check out our Feature Specifications and Design Meeting Notes or follow us on Twitter and Facebook to stay up to date with what our team is working on.