从EF 4升级到EF 5

时间:2020-11-29 23:12:22

My application is based on .NET 4.0 and EF 4. I'm now looking at upgrading to the latest versions.

我的应用程序基于.NET 4.0和EF 4.我现在正在考虑升级到最新版本。

  • Are there any breaking changes or behavioral differences that may adversely affect my application?
  • 是否存在可能对我的申请产生不利影响的重大变化或行为差异?

  • How easy is the upgrade path? Does upgrading to EF 5 require any code changes or other work?
  • 升级路径有多容易?升级到EF 5是否需要更改代码或其他工作?

  • Are there any new features related to code-first that would be worth upgrading for?
  • 是否有任何与代码优先相关的新功能值得升级?

2 个解决方案

#1


5  

How easy is the upgrade path? Does upgrading to EF 5 require any code changes or other work?

升级路径有多容易?升级到EF 5是否需要更改代码或其他工作?

You'll have to upgrade to .net 4.5 for most new features to work.

您必须升级到.net 4.5才能使用大多数新功能。

Are there any new features related to code-first that would be worth upgrading for?

是否有任何与代码优先相关的新功能值得升级?

Not exactly related to code-first, because it's crosscutting, but still worth mentioning: Enum support.

与代码优先不完全相关,因为它是横切的,但仍然值得一提:Enum支持。

#2


11  

EDIT: First of all, EF 5/.NET 4.5 has a major concern in that is will never support Windows XP or Server 2003 (or earlier). If you need support for either of those OS's, use EF 4.4 with .NET 4.0, which has none of the fun new stuff.

编辑:首先,EF 5 / .NET 4.5有一个主要问题,即永远不会支持Windows XP或Server 2003(或更早版本)。如果您需要支持这些操作系统中的任何一个,请使用带有.NET 4.0的EF 4.4,它没有任何有趣的新功能。

Also, I hit a (simple) breaking change relating to DataAnnotations moving namespaces:

此外,我遇到了与DataAnnotations移动命名空间相关的(简单)重大更改:

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.

实体框架4.1至4.3在EntityFramework程序集的System.ComponentModel.DataAnnotations命名空间中包含其他数据注释。在.NET 4.5中,这些注释被移动为System.ComponentModel.DataAnnotations.dll程序集的System.ComponentModel.DataAnnotations.Schema命名空间中的.NET Framework的一部分。如果您使用的是EF 4.x并以.NET 4.5为目标,则会在不同的程序集中生成两个具有相同名称的数据注释。

See http://blogs.msdn.com/b/adonet/archive/2012/02/29/ef4-3-1-and-ef5-beta-1-available-on-nuget.aspx, which still applies in EF 5 RTM.

请参阅http://blogs.msdn.com/b/adonet/archive/2012/02/29/ef4-3-1-and-ef5-beta-1-available-on-nuget.aspx,它仍适用于EF 5 RTM。

In short, I had to add:

简而言之,我不得不补充:

using System.ComponentModel.DataAnnotations; // had this already
using System.ComponentModel.DataAnnotations.Schema; // needed this one

to a zillion places.

到了无数的地方。

#1


5  

How easy is the upgrade path? Does upgrading to EF 5 require any code changes or other work?

升级路径有多容易?升级到EF 5是否需要更改代码或其他工作?

You'll have to upgrade to .net 4.5 for most new features to work.

您必须升级到.net 4.5才能使用大多数新功能。

Are there any new features related to code-first that would be worth upgrading for?

是否有任何与代码优先相关的新功能值得升级?

Not exactly related to code-first, because it's crosscutting, but still worth mentioning: Enum support.

与代码优先不完全相关,因为它是横切的,但仍然值得一提:Enum支持。

#2


11  

EDIT: First of all, EF 5/.NET 4.5 has a major concern in that is will never support Windows XP or Server 2003 (or earlier). If you need support for either of those OS's, use EF 4.4 with .NET 4.0, which has none of the fun new stuff.

编辑:首先,EF 5 / .NET 4.5有一个主要问题,即永远不会支持Windows XP或Server 2003(或更早版本)。如果您需要支持这些操作系统中的任何一个,请使用带有.NET 4.0的EF 4.4,它没有任何有趣的新功能。

Also, I hit a (simple) breaking change relating to DataAnnotations moving namespaces:

此外,我遇到了与DataAnnotations移动命名空间相关的(简单)重大更改:

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.

实体框架4.1至4.3在EntityFramework程序集的System.ComponentModel.DataAnnotations命名空间中包含其他数据注释。在.NET 4.5中,这些注释被移动为System.ComponentModel.DataAnnotations.dll程序集的System.ComponentModel.DataAnnotations.Schema命名空间中的.NET Framework的一部分。如果您使用的是EF 4.x并以.NET 4.5为目标,则会在不同的程序集中生成两个具有相同名称的数据注释。

See http://blogs.msdn.com/b/adonet/archive/2012/02/29/ef4-3-1-and-ef5-beta-1-available-on-nuget.aspx, which still applies in EF 5 RTM.

请参阅http://blogs.msdn.com/b/adonet/archive/2012/02/29/ef4-3-1-and-ef5-beta-1-available-on-nuget.aspx,它仍适用于EF 5 RTM。

In short, I had to add:

简而言之,我不得不补充:

using System.ComponentModel.DataAnnotations; // had this already
using System.ComponentModel.DataAnnotations.Schema; // needed this one

to a zillion places.

到了无数的地方。