38

我将 EF 5.0 安装到 .DAL 中,现在我想从 Nuget 将 EF 5.0 安装到 .BLL

但是默认的在线 Nuget 包总是提供 6.0,与我在 DAL 中使用的 5.0 EF 一起使用时会出错。

我在哪里可以将 EntityFramework 的 5.0 版本安装到我的 Nuget 包中?

4

3 回答 3

71

查看 -> 其他窗口 -> 包管理器控制台,然后运行 install-package entityframework -version 5.0.0.0​​.

-project <project.name>如果您想将其安装在特定项目中,请添加。

于 2013-11-13T14:56:17.350 回答
14

here is what I experienced: (before I begin... kudos to devnull for the answer).

I clicked on:

1) View -> Other windows -> Package Manager Console then ran

2) install-package entityframework -version 5.0.0.0.

The uninstall started, but then rolled back, as it detected I already had installed Entity Framework (EF) 6.0.2 ...

>PM> install-package entityframework -version 5.0.0.0

Installing 'EntityFramework 5.0.0'. You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=253898&clcid=0x409. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device. Successfully installed 'EntityFramework 5.0.0'. *****Install failed. Rolling back...***** install-package : Already referencing a newer version of 'EntityFramework'. At line:1 char:1 + install-package entityframework -version 5.0.0.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

So then I uninstalled the Entity Framework 6.0.2 and found it had a dependency that also needed to be removed... then I was finally able to uninstall the Entity Framework 6.0.2 and then add the Entity Framework 5.0.0.0

PM> uninstall-package entityframework -version 6.0.2 uninstall-package : Unable to uninstall 'EntityFramework 6.0.2' because 'AnotherFakeDbSet 3.0.0.0' depends on it.

So then I uninstalled these two and installed Entity Framework 5.0.0.0

PM> uninstall-package AnotherFakeDbSet -version 3.0.0.0

PM> uninstall-package entityframework -version 6.0.2

PM> install-package entityframework -version 5.0.0.0

I like the console... quicker than searching for the packages if you know the version #. And if you haven't checked out "Powershell" (the basis for the console -- I find it's time well spent - it allows for virtually unlimited automation)

于 2013-12-17T16:29:42.190 回答
0

实体框架或其他类似包的旧版本只能在 Visual Studio 的早期版本(2015 之前)中使用包管理器控制台安装。在 Visual Studio 2015 中,有一个在安装前手动选择版本的选项,但在 Visual Studio 2010、2012 中,您只需要使用包管理器控制台。

只需浏览到Nuget Explorer链接,然后单击您必须安装的特定实体版本。

您将看到 Studio 自动显示包管理器控制台代码。

例如,我正在开发一个需要 Entity Framework 4.1 的项目,所以这是我的代码。实体框架包管理器控制台命令快照

于 2016-07-06T08:51:12.583 回答