Today we are pleased to announce the RTM of Entity Framework 6. The RTM of Visual Studio 2013 was also released today – you can read more about this release on Soma’s blog. Be sure to save the date for Visual Studio 2013 Launch on Nov 13th.

 

Getting EF6

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 version of Entity Framework runtime.

The tooling for Visual Studio 2013 is included in-the-box. If you are using Visual Studio 2012, the tooling is available on the Microsoft Download Center. You only need to 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.

 

What’s New in EF6

Tooling

The focus for the tooling in EF6 was to add support for the EF6 runtime and to enable shipping out-of-band between releases of Visual Studio.

The tooling itself does not include any new features, but most of the new runtime features can be used with models created in the EF Designer.

Runtime

The following features work for models created with Code First or the EF Designer:

  • Async Query and Save adds support for the task-based asynchronous patterns that were introduced in .NET 4.5.
  • Connection Resiliency enables automatic recovery from transient connection failures.
  • Code-Based Configuration gives you the option of performing configuration – that was traditionally performed in a config file – in code.
  • 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.
  • Interception/SQL logging provides low-level building blocks for interception of EF operations with simple SQL logging built on top.
  • Testability improvements make it easier to create test doubles for DbContext and DbSet when using a mocking framework or writing your own test doubles.
  • 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).
  • Improved Transaction Support provides support for a transaction external to the framework as well as improved ways of creating a transaction within the Framework.
  • 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.
  • Improved performance of Enumerable.Contains in LINQ queries.
  • Improved warm up time (view generation), especially for large models. 
  • Pluggable Pluralization & Singularization Service.
  • Custom implementations of Equals or GetHashCode on entity classes are now supported.
  • DbSet.AddRange/RemoveRange provides an optimized way to add or remove multiple entities from a set.
  • DbChangeTracker.HasChanges provides an easy and efficient way to see if there are any pending changes to be saved to the database.
  • SqlCeFunctions provides a SQL Compact equivalent to the SqlFunctions.

The following features apply to Code First only:

  • 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.
  • Code First Mapping to Insert/Update/Delete Stored Procedures is now supported.
  • Idempotent migrations scripts allow you to generate a SQL script that can upgrade a database at any version up to the latest version.
  • 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.
  • 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.
  • 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.
  • DbModelBuilder.Configurations.AddFromAssembly method allows you to easily add all configuration classes defined in an assembly when you are using configuration classes with the Code First Fluent API. 
  • Custom Migrations Operations enabled you to add additional operations to be used in your code-based migrations.
  • Default transaction isolation level is changed to READ_COMMITTED_SNAPSHOT for databases created using Code First, allowing for more scalability and fewer deadlocks.
  • Entity and complex types can now be nested inside classes.

 

Improving Startup Performance

The 6.0.1 Patch Release

The 6.0.0 version of the EF package needed to be locked down early to be included in Visual Studio, ASP.NET, etc. After this lock down a number of important issues came to our attention that we felt were important to fix ASAP.

To deal with this, we are also publishing an EF 6.0.1 patch on NuGet today. If you install from NuGet you will automatically get the latest patch version. If you use a VS2013 project template that already has EF6 installed, or if the EF6 tooling installs the NuGet package for you, we would recommend updating to the latest patch version. You can do this by running Update-Package EntityFramework in Package Manager Console.

The 6.0.1 patch release is limited to fixing issues that were introduced in the EF6 release (regressions in performance/behavior since EF5). The most notable changes are to fix some performance issues during warm-up for EF models – this was important to us as we significantly improved model warm-up time in other areas in EF6 and have been listing it as a feature. You can see a complete list of the individual fixes on our CodePlex site.

Improving Performance with Ngen

Prior to EF6, a large portion of Entity Framework was included in the .NET Framework. This meant that most of Entity Framework automatically has native image generation run on it to reduce the just-in-time (JIT) compilation cost.

Because EF6 ships as a completely out-of-band release, native image generation is no longer performed automatically. This can result in an increased warm-up time for your application while JIT compilation occurs – we have seen results of around 1 second.

To remove this JIT time you can use Ngen to generate native images for the Entity Framework assembly on your machine. For more information, see Improving Startup Performance with NGen.

 

Contributors

For EF6 we moved to an open source development model. We would like to thank the following contributors for helping to make EF6 a great release.

 

What’s Next

We’re currently in the planning phase for the releases that will follow EF6. We’ll post up a roadmap and plans once we’ve got something a little more concrete.