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.


 

Today we are pleased to announce the release of two new versions of the EntityFramework NuGet package.

The 4.3.1 version includes some bug fixes for the 4.3 package we released a few weeks ago. We are also making the first beta of EF 5 available as a pre-release package.

 


What’s in 5.0.0-beta1

This is the first preview of EF 5 and includes all the features and bug fixes in EF 4.3.1 in addition to a number of new features that are available in applications targeting .NET Framework 4.5. (You will need Visual Studio 11 Beta to work with the .NET Framework 4.5)

  • Enum support allows you to have enum properties in your entity classes. This new feature is available for Model, Database and Code First.
  • Table-Valued functions in your database can now be used with Database First.
  • Spatial data types can now be exposed in your model using the DbGeography and DbGeometry types. Spatial data is supported in Model, Database and Code First.
  • The Performance enhancements that we recently blogged about are included in EF 5 Beta 1.
  • Visual Studio 11 includes LocalDb rather than SQLEXPRESS. The EntityFramework NuGet package will now check which database is available when the package is installed and use a configuration file setting to set the default database server that Code First databases will be created on. If SQLEXPRESS is running, it will be used. If SQLEXPRESS is not available then LocalDb will be registered as the default instead.

The following new features are also available in the Entity Model Designer in Visual Studio 11 Beta:

  • Multiple-diagrams per model allows you to have several diagrams that visualize subsections of your overall model.
  • Shapes on the design surface can now have coloring applied.
  • Batch import of stored procedures allows multiple stored procedures to be added to the model during model creation.

 

Known Issues

We will keep this list updated with known issues for this release:

  • There is a known issue using the Code First Migrations commands in Visual Studio 2010. We are working on an updated package that addresses this issue. You will receive the following error when using migrations commands from EF 5 Beta 1 in Visual Studio 2010:
    Could not load file or assembly 'Microsoft.VisualStudio.Shell.10.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
  • There is a known issue in MVC4 applications in Visual Studio 11 that is described in more detail here.

.

Getting Started

You can get EF 5 Beta 1 by installing the latest pre-release version of the EntityFramework NuGet package.

InstallPackage

These existing walkthroughs provide a good introduction to using the Code First, Model First & Database First workflows available in Entity Framework:

We have created walkthroughs for the new features in EF 5:

 

Compatibility

This version of the NuGet package is fully compatible with Visual Studio 11 Beta and can be used for applications targeting .NET 4.0 and 4.5.

The new features listed above will only be available when writing an application that targets .NET 4.5.

EF 5 will work with Visual Studio 2010 but there is currently a known issue that prevents the Code First Migrations commands from being used in Visual Studio 2010. See the Known Issues section (above) for more details.

 


What’s in 4.3.1?

A few weeks back we released EF 4.3, which included the new Code First Migrations feature and a few bug fixes. Today we are releasing the 4.3.1 patch release that includes some bug fixes to the 4.3 release.

This is a fully supported go-live release.

The changes in 4.3.1 compared to 4.3 include:

  • Templates for using DbContext with Model First and Database First have been renamed from ADO.NET DbContext Generator to EF 4.x DbContext Generator. We made this rename to easily distinguish between the EF 5.x DbContext Generator that is to be used for EF 5 applications.
  • Added the ability to enable Code First Migrations against an existing database. Julie Lerman blogged about using an empty initial migration to capture the initial state of the model when it is in sync with an existing database. Once this migration is generated Code First Migrations will correctly detect and scaffold changes to your model. You can now use the –IgnoreChanges to tell Code First Migrations not to scaffold any code for this initial migration (i.e. ‘Add-Migration InitialMigration –IgnoreChanges).
  • Visual Studio 11 includes LocalDb rather than SQLEXPRESS. The EntityFramework NuGet package will now check which database is available when the package is installed and use a configuration file setting to set the default database server that Code First databases will be created on. If SQLEXPRESS is running, it will be used. If SQLEXPRESS is not available then LocalDb will be registered as the default.
  • Fixed issue where TPC mapping in Code First was generating “Unknown Columnname” exceptions when accessing the database.
  • Fixed issue where hard coded column data types were not honored in generated databases. If you used the Column data annotation or HasColumnType Fluent API method to hard code a column data type (i.e. xml, money, etc.), this data type was not used when creating the database.
  • Fixed issue preventing decimal columns from being configured with the ‘Identity’ store generated pattern.
  • We now provide a better exception message when context/database initialization fails due to connectivity issues with the database.
  • Enabled support for configsource in configuration files when using Code First Migrations.
  • Fixed issues using Moq with DbContext – as reported in this Stack Overflow question.

 

Getting Started

You can get EF 4.3.1 by installing the latest version of the EntityFramework NuGet package.

InstallEntityFramework

Check out the EF 4.3 release post for details and walkthroughs for EF 4.3.

 

Compatibility

This version of the NuGet package is fully compatible with Visual Studio 2010 and Visual Studio 11 Beta. It is designed to be used when writing .NET 4.0 applications.

If writing a .NET 4.5 application we recommend using the 5.0.0-beta1 version of the package instead. You can use the package in .NET 4.5 applications but you should be aware of the following known issue:

Entity Framework 4.1 thru 4.3 included additional data annotations in the System.ComponentModel.DataAnnotations namespace in the EntityFramework assembly. In .NET 4.5 these annotations were moved to be part of the .NET Framework in the System.ComponentModel.DataAnnotations.Schema namespace of the System.ComponentModel.DataAnnotations.dll assembly. If you are using EF 4.x and targeting .NET 4.5 this results in two data annotations with the same name in different assemblies. Because the annotations in the .NET Framework are in a different namespace we were not
able to use type forwarding to avoid this conflict.

If you are not using the affected data annotations there is no impact on your code. If you are using the data annotations in a C# project you can use the extern modifier to ensure your code uses the annotations from EntityFramework.dll (http://msdn.microsoft.com/en-us/library/e59b22c5(v=VS.80).aspx). If you use the new annotations from the System.ComponentModel.DataAnnotations.dll assembly in .NET 4.5

 


Support

We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow.

We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

 

Entity Framework Team