VS2010环境中使用EF3.0(原创)
VS2010环境中使用EF3.0
1.打开VS2010->工具->Library Package Manager->Package Manager Console
这个时候下面会显示红色的错误:
Error: The Package Manager Console requires PowerShell 2.0 runtime,
which is not detected on this machine. Please install the PowerShell
2.0 from http://support.microsoft.com/kb/968929 and restart Visual
Studio.
解决方案:
http://www.microsoft.com/downloads/zh-cn/details.aspx?
FamilyID=60cb5b6c-6532-45e0-ab0f-a94ae9ababf5
打开这个网页选择语言,系统,下载,安装。装好就OK了
2.再次按第1步进入Package Manager Console的PM>命令行界面
输入 Install-Package EntityFramework -Version 4.3.0 按回车后
又报错误了:
----------------------------------------------------------------------
Install-Package : The current environment doesn't have a solution open.
所在位置 行:1 字符: 16
+ Install-Package <<<< EntityFramework -Version 4.3.0
+ CategoryInfo : InvalidOperation: (:) [Install-Package],
InvalidOperationException
+ FullyQualifiedErrorId :
NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand
----------------------------------------------------------------------
解决方案:
根据错误提示,原来是需要打开一个项目的解决方案再能执行
这里我打开一个FLSoft.Blog解决方案后再次执行命令行,然后显示成功
----------------------------------------------------------
PM> Install-Package EntityFramework -Version 4.3.0
You are downloading EntityFramework from Microsoft, the license
agreement to which is available at http://go.microsoft.com/fwlink/?
LinkId=239742. 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 4.3.0'.
Successfully removed 'EntityFramework 4.1.10331.0' from FLSoft.Blog.
Successfully uninstalled 'EntityFramework 4.1.10331.0'.
Successfully added 'EntityFramework 4.3.0' to FLSoft.Blog.
----------------------------------------------------------