简体   繁体   English

我的项目中安装了哪个版本的Entity Framework?

[英]Which version of Entity Framework is installed in my project?

I just used Nuget to install Entity Framework 4.3.1 in my project. 我只是用Nuget在我的项目中安装Entity Framework 4.3.1。 When I check the references, they say System.Data.Entity is version 4.0.0 . 当我检查引用时,他们说System.Data.Entity是版本4.0.0 Runtime Version is v4.0.30319 . 运行时版本为v4.0.30319

  1. Is this correct for EF version 4.3.1? 这对于EF 4.3.1版是否正确? I assumed it would say 4.3.1 ..? 我以为它会说4.3.1 ..?

    Also when I check the directory of the referenced dll (in C:\\Program Files..\\.NETFramework\\v4.0\\System.Data.Entity.dll ), the date of the file is 18/03/2010 . 另外,当我检查引用的dll的目录(在C:\\Program Files..\\.NETFramework\\v4.0\\System.Data.Entity.dll )中时,文件的日期为18/03/2010

    According to WikiPedia: 根据WikiPedia:

    The version 4.3.1 was released on February 29, 2012 版本4.3.1于2012年2月29日发布

  2. Shouldn't this mean the date of the file should be closer to 2012? 这不是意味着文件的日期应该接近2012年吗?

    When I use Nuget Get-Package it says the version installed is 4.3.1, but I don't want to use Nuget to install EF 4.3.1 on other projects. 当我使用Nuget Get-Package它说安装的版本是4.3.1,但是我不想使用Nuget在其他项目上安装EF 4.3.1。

  3. Where is the Entity Framework 4.3.1 dll so I can just add a reference to it in to other projects? Entity Framework 4.3.1 dll在哪里,因此我可以将其引用添加到其他项目中?

Thanks. 谢谢。

When you install Entity Framework in your project, as: 在项目中安装实体框架时,如下所示:

Install-Package EntityFramework -Version 4.3.1

you will end up with a EntityFramework.dll file that if you open its properties will have the exact version specified in the installing command: 您将得到一个EntityFramework.dll文件,如果打开它的属性,它将具有在安装命令中指定的确切版本:

在此处输入图片说明

and, if you double click the reference in your project, you will see the same: 并且,如果双击项目中的引用,您将看到相同的内容:

在此处输入图片说明

DO NOT make confusion with System.Data.dll that is the data layer of the .NET Framework where you can find many classes to handle data, like DataRow and DataTable part of ADO.NET for example... 不要System.Data.dll混淆,后者是.NET Framework的数据层 ,您可以在其中找到许多类来处理数据,例如ADO.NET的DataRowDataTable部分。


from comment: 来自评论:

After I install 4.3.1, how do I migrate my project to use the new version? 安装4.3.1之后,如何迁移项目以使用新版本?

there are very big differences between the first version and 4.x, you will have some work changing code, but here's what you need to do: 第一个版本和4.x之间有很大的不同,您将需要一些更改代码的工作,但是这是您需要做的:

Version 1 of EF was included in .NET Framework 3.5 SP1 , and was called "ADO.NET Entity Framework" (now it's only Entity Framework ) so there's no separated dll file. EF的第1版包含在.NET Framework 3.5 SP1中 ,并称为“ ADO.NET实体框架”(现在它是唯一的Entity Framework ),因此没有单独的dll文件。

  1. install EF 4.3.1 from nuget 从nuget安装EF 4.3.1
  2. change all references in your project that work with data to use System.Data to use EntityFramework 更改项目中所有与数据一起使用的引用以使用System.Data以使用EntityFramework
  3. see what's going on and change every line that has issues when compiling 查看正在发生的事情,并在编译时更改出现问题的每一行

In your case, what I would do would be more generic: 在您的情况下,我会做的更通用:

  1. I would create a new Library project where I would install EF 我将创建一个新的图书馆项目,在其中安装EF
  2. then I would create a repository using EF with the current backup of the db schema 然后我将使用EF与数据库架构的当前备份来创建存储库
  3. I would also create a test project and place some tests around the project like calling adding and updating something 我还将创建一个测试项目,并围绕该项目进行一些测试,例如调用添加和更新内容
  4. after everything was fine, I would then replace all my original calls of data to use the new Repository (with EF 4) and test the whole project... 在一切正常之后,我将替换所有原始数据调用以使用新的存储库(带有EF 4)并测试整个项目...

在您的项目中,展开“参考”部分并检查属性应显示实体框架的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM