如果点击“工具”菜单,没有"Library Package Manager"子菜单,可以点击“扩展管理器”然后进行下载。并安装。如下图所示。重新启动VS即可。搜索关键字为“NuGet”
点击“工具”菜单下的“Library Package Manager”子菜单下的“ Package Manager Console”菜单选项,如图所示。
在窗口中输入如下命令后回车,如图所示
Install-Package EFCodeFirst
就安装成功了。
如果上述的安装方式不可以,可以试试详细安装步骤。
详细步骤如下:
1.先输入:get-package -remote -filter entityframework 取出相应的版本号。
2.然后安装需要的包和版本:install-package -id EFCodeFirst -Version 1.1
运行结果为:
PM> install-package -id EFCodeFirst -Version 1.1
未安装“EntityFramework (≥ 4.1.10331.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”
已成功安装“EFCodeFirst 1.1”
已成功将“EntityFramework 4.1.10331.0”添加到 EFWebSite
已成功将“EFCodeFirst 1.1”添加到 EFWebSite
第二步中:两个参数,一个是Id,一个是Version。
install-package -id 包名 -Version 版本
如安装EntityFramework。
那么输入:install-package -id EntityFramework -Version 4.1.10331.0 即可。