This package (or one of its dependencies) contains PowerShell scripts and needs to be installed from the Package Manager Console.
背景①:利用NuGet来安装EFCodeFirst方法
①我们可以利用NuGet包管理器(安装ASP.NET MVC3时会自动安装)来把EFCodeFirst类库添加到我们的Mvc工程中。这个类库使得我们可以直接使用code-first。点击“工具”菜单下的“Library Package Manager”子菜单下的“Add Library Package Reference”菜单选项;
②点击“Add Library Package Reference”菜单选项后,将会弹出一个对话框,标题为“Add Library Package Reference”;
③默认状态下,左边的“All”选项处于选择状态。因为还没有安装任何包,所以右边面板中显示“找不到任何项”。点击左边面板中的“online”选项,NuGet包管理器将会在服务器上检索所有当前能够获取的包;
④服务器上有几百个当前能够获取的包,现在我们只关注EFCodeFirst包。在右上角的搜索输入框中输入“EFCode”。在检索结果中,选择EFCodeFirst包,并且点击Install按钮安装包;
⑤点击了install按钮后,会弹出一个接受许可证窗口,在这个窗口中必须要点击“I Accept”按钮,接受许可证条款,安装才能继续进行。
⑥安装完毕后,点击close按钮。我们的Mvc工程中会自动加载EntityFramework程序集,其中包含了EFCodeFirst类库。
如果上面的方法 不能安装,再尝试下面的方法。缺少PowerShell支持。
1、
在XP系统中,可以下载下面的补丁: http://www.microsoft.com/downloads/zh-cn/details.aspx?FamilyID=60cb5b6c-6532-45e0-ab0f-a94ae9ababf5 安装好后就OK了。
2、在win7的系统的解决方法:
后来根据提示找到了一个在控制台进行安装的解决方法:
①博客园原文内容如下:
I tried to install EntityFramework 4.1 on VS 2010 through NuGet. I searched and found the package through “Tools > Library Package Manager > Add Library Package Reference” tool and I got this error: “This package (or one of its dependencies) contains powershell scripts and needs to be installed from the package manager console.”. This is what I did to fix it:
Tools > Library Package Manager > Package Manager Console
PM > get-package -remote -filter entityframework
(got some results including EntityFramework 4.1.10311.0)
PM > install-package -id EntityFramework 或者输入 install-package -id EntityFramework -Version 4.1.10311.0
Successfully added ‘EntityFramework …
②根据提示,在控制台安装会出现如下信息(以下蓝色内容为需要输入的命令):
Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.
PM> get-package -remote -filter entityframework
Id Version Description
– ——- ———–
Check_My_Box_Packages 1.1.0.2 This Package uses MvcScaffolding, EntityFramew…
Check_My_Box_Packages 1.1.0.3 This Package uses MvcScaffolding, EntityFramew…
EFCodeFirst 1.0 Legacy package, Code First is now included in …
EFCodeFirst 1.1 Legacy package, Code First is now included in …
EntityFramework 4.1.10311.0 DbContext API and Code First workflow for ADO….
EntityFramework 4.1.10331.0 DbContext API and Code First workflow for ADO….
EntityFramework.Patterns 0.2 Provides different patterns to be used with En…
EntityFramework.Sample 4.1 This sample blog model demonstrates the use of…
EntityFramework.SqlServerCompact 4.1.8482.1 Allows SQL Server Compact 4.0 to be used with …
EntityFrameworkProfiler 1.0.0.839 EntityFramework Profiler is a real-time visual…
PM> install-package -id EntityFramework 或者输入 install-package -id EntityFramework -Version 4.1.10311.0
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkID=211010. 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.
已成功安装“EntityFramework 4.1.10331.0”
已成功将“EntityFramework 4.1.10331.0”添加到 MvcMovie
PM>