Are there technical reasons EF 5 isn't fully s

2019-02-12 14:25发布

问题:

I wanted to upgrade my app to EF 5 to take advantage of features like support for enum spatial etc. However, I was not able to upgrade unless I move to .Net 4.5.

I would like to know what features of .Net 4.5 does EF 5 use that it can not be done in .Net 4.0?

回答1:

My understanding is that EF >= 4.1 (including EF 5) consists of

  • the EF "core libraries" like (System.Data.Entity.dll) which are part of the .NET Framework
  • the additional package/assembly you can download via Nuget which contains the DbContext API and Code-First development

There were plans and an attempt in summer 2011 (the Entity Framework June 2011 CTP) to release the enum, spatial support and other new features (except Code-First Migrations) as an update of the core librares before .NET 4.5 is released. But the EF team has decided that such out-of-band updates are possible for the NuGet package (that's why EF 4.3 already has the Migrations feature that didn't require to touch the core libraries), but for the core libraries they are too difficult and can't be done before .NET 4.5 release:

There are two logical parts to the Entity Framework, the core components that ship inside the .NET Framework and Visual Studio and the ‘out of band’ components that we can update on a much more frequent schedule. We are currently looking at how we can update the core components on a more frequent cadence as well. The ‘EF June 2011 CTP’ was our first attempt at shipping the core components more frequently and it’s become clear we’re just not technically ready to do this yet.

Core components include:

  • Core EF Runtime (System.Data.Entity.dll & System.Web.Entity.dll)
  • EF Designer

Out of band components include: (We will likely ship more out of band components in the future)

  • The DbContext API & Code First (EntityFramework.dll)
  • T4 Templates for using DbContext API with Model First & Database First
  • EF Power Tools
  • Code First Migrations

(Quote from here.)

That means that enum support for EF will be part of the .NET 4.5 core libraries and not of the downloadable EF 5 NuGet package. Hence the new EF features like enum and spatial support are not available together with .NET 4.0.

More about the history and reason of separating "EF Core libraries" from "EF NuGet package" is here: http://blogs.msdn.com/b/adonet/archive/2011/10/18/how-we-talk-about-ef-and-its-future-versions.aspx