选择 EF 设计器模型实体框架运行时版本Selecting Entity Framework Runtime Version for EF Designer Models

备注

仅限 EF6 及更高版本 - 此页面中讨论的功能、API 等已引入实体框架 6。EF6 Onwards Only - The features, APIs, etc. discussed in this page were introduced in Entity Framework 6. 如果使用的是早期版本,则部分或全部信息不适用。If you are using an earlier version, some or all of the information does not apply.

从 EF6 开始,将以下屏幕添加到 EF 设计器,以便在创建模型时选择想要面向的运行时版本。Starting with EF6 the following screen was added to the EF Designer to allow you to select the version of the runtime you wish to target when creating a model. 当项目中尚未安装最新版本的实体框架时,将显示该屏幕。The screen will appear when the latest version of Entity Framework is not already installed in the project. 如果已安装最新版本,则默认情况下将使用它。If the latest version is already installed it will just be used by default.

选择运行时版本

面向 EF6. xTargeting EF6.x

你可以从 "选择你的版本" 屏幕中选择 "EF6",将 EF6 运行时添加到你的项目。You can choose EF6 from the 'Choose Your Version' screen to add the EF6 runtime to your project. 添加 EF6 后,你将停止在当前项目中看到此屏幕。Once you've added EF6, you’ll stop seeing this screen in the current project.

如果已安装旧版本的 EF,EF6 将被禁用 (因为不能将多个版本的运行时) 的项目作为目标。EF6 will be disabled if you already have an older version of EF installed (since you can't target multiple versions of the runtime from the same project). 如果此处未启用 EF6 选项,请按照以下步骤将项目升级到 EF6:If EF6 option is not enabled here, follow these steps to upgrade your project to EF6:

  1. 在解决方案资源管理器中右键单击项目,然后选择 "管理 NuGet 包 ... "Right-click on your project in Solution Explorer and select Manage NuGet Packages...
  2. 选择 更新Select Updates
  3. 选择 EntityFramework (确保它将更新为所需版本) Select EntityFramework (make sure it is going to update it to the version you want)
  4. 单击 "更新"Click Update

 

面向 EF5. xTargeting EF5.x

你可以从 "选择你的版本" 屏幕中选择 "EF5",将 EF5 运行时添加到你的项目。You can choose EF5 from the 'Choose Your Version' screen to add the EF5 runtime to your project. 添加 EF5 后,仍会看到此屏幕,其中 "EF6" 选项处于禁用状态。Once you've added EF5, you’ll still see the screen with the EF6 option disabled.

如果已安装 EF4 版本的运行时,则会看到屏幕上列出的 EF 版本(而不是 EF5)。If you have an EF4.x version of the runtime already installed then you will see that version of EF listed in the screen rather than EF5. 在这种情况下,可以使用以下步骤升级到 EF5:In this situation you can upgrade to EF5 using the following steps:

  1. 选择 工具- > 库包管理器- > 程序包管理器控制台Select Tools -> Library Package Manager -> Package Manager Console
  2. 运行 安装包 EntityFramework-版本 5.0.0Run Install-Package EntityFramework -version 5.0.0

 

面向 EF4. xTargeting EF4.x

可以使用以下步骤将 EF4 运行时安装到项目中:You can install the EF4.x runtime to your project using the following steps:

  1. 选择 工具- > 库包管理器- > 程序包管理器控制台Select Tools -> Library Package Manager -> Package Manager Console
  2. 运行 安装包 EntityFramework-版本 4.3.0Run Install-Package EntityFramework -version 4.3.0