升级到EF6 两个注意事项

1、依据MSDN的官方描述:

In previous versions of EF the code was split between core libraries (primarily System.Data.Entity.dll) shipped as part of the .NET Framework and out-of-band (OOB) libraries (primarily EntityFramework.dll) shipped in a NuGet package. EF6 takes the code from the core libraries and incorporates it into the OOB libraries. This was necessary in order to allow EF to be made open source. The consequence of this is that applications will need to be rebuilt against the moved types.

This should be straightforward for applications that make use of DbContext as shipped in EF 4.1 and later. A little more work is required for applications that make use of ObjectContext but it still isn’t hard to do.
在之前的EF版本中,代码被分割为主要的库(System.Data.Entity.dll)--作为.NET Framework的一部分载入,以及外围的库(主要就是 EntityFramework.dll)--作为NuGet载入。
EF6将代码从核心库去除,然后将其合并到外围库中。这是必须的,因为这样可以使EF成为open source。这么做的后果就是应用必须根据移除的类型做重新的生成。
这一点对于在EF4.1或其后的版本中使用DbContext的应用来说是没问题的。而使用ObjectContext的应用还需要做一点并不难的工作。

2、EF 4.1.10031.0(自己机器上的版本)添加实体数据模型时,默认生成的是ObjectContext。

而升级到EF5和EF6时,则默认生成的是DbContext。虽然两种数据库映射模型可以互转。但在更新的版本中官方推荐DbContext。

原文地址:https://www.cnblogs.com/Benjamin/p/3520621.html