Visual Studio 版本Visual Studio Releases

建议始终使用最新版本的 Visual Studio,因为它包含适用于 .NET、NuGet 和实体框架的最新工具。We recommend to always use the latest version of Visual Studio because it contains the latest tools for .NET, NuGet, and Entity Framework. 事实上,实体框架文档中的各种示例和演练都假设你使用的是最新版本的 Visual Studio。In fact, the various samples and walkthroughs across the Entity Framework documentation assume that you are using a recent version of Visual Studio.

不过,只要考虑一些差异,就有可能使用不同版本的 Visual Studio 的较旧版本实体框架:It is possible however to use older versions of Visual Studio with different versions of Entity Framework as long as you take into account some differences:

Visual Studio 2017 15.7 及更高版本Visual Studio 2017 15.7 and newer

  • 此版本的 Visual Studio 包括实体框架工具和 EF 6.2 运行时的最新版本,不需要执行其他设置步骤。This version of Visual Studio includes the latest release of Entity Framework tools and the EF 6.2 runtime, and does not require additional setup steps. 有关这些版本的详细信息,请参阅 新增功能See What's New for more details on these releases.
  • 使用 EF 工具将实体框架添加到新项目将自动添加 EF 6.2 NuGet 包。Adding Entity Framework to new projects using the EF tools will automatically add the EF 6.2 NuGet package. 可以手动安装或升级到联机提供的任何 EF NuGet 包。You can manually install or upgrade to any EF NuGet package available online.
  • 默认情况下,此版本的 Visual Studio 中可用的 SQL Server 实例为 LocalDB 实例,名为 MSSQLLocalDB。By default, the SQL Server instance available with this version of Visual Studio is a LocalDB instance called MSSQLLocalDB. 应使用的连接字符串的服务器部分是 " (localdb) \ MSSQLLocalDB"。The server section of connection string you should use is "(localdb)\MSSQLLocalDB". @ \ \ 在 c # 代码中指定连接字符串时,请记住使用前缀为或双反斜杠 "" 的逐字字符串。Remember to use a verbatim string prefixed with @ or double back-slashes "\\" when specifying a connection string in C# code.

Visual Studio 2015 到 Visual Studio 2017 15。6Visual Studio 2015 to Visual Studio 2017 15.6

  • 这些版本的 Visual Studio 包括实体框架工具和运行时 ef6.1.3。These versions of Visual Studio include Entity Framework tools and runtime 6.1.3. 有关这些版本的详细信息,请参阅 以前的版本See Past Releases for more details on these releases.
  • 使用 EF 工具向新项目添加实体框架会自动添加 EF ef6.1.3 NuGet 包。Adding Entity Framework to new projects using the EF tools will automatically add the EF 6.1.3 NuGet package. 可以手动安装或升级到联机提供的任何 EF NuGet 包。You can manually install or upgrade to any EF NuGet package available online.
  • 默认情况下,此版本的 Visual Studio 中可用的 SQL Server 实例为 LocalDB 实例,名为 MSSQLLocalDB。By default, the SQL Server instance available with this version of Visual Studio is a LocalDB instance called MSSQLLocalDB. 应使用的连接字符串的服务器部分是 " (localdb) \ MSSQLLocalDB"。The server section of connection string you should use is "(localdb)\MSSQLLocalDB". @ \ \ 在 c # 代码中指定连接字符串时,请记住使用前缀为或双反斜杠 "" 的逐字字符串。Remember to use a verbatim string prefixed with @ or double back-slashes "\\" when specifying a connection string in C# code.

Visual Studio 2013Visual Studio 2013

  • 此版本的 Visual Studio 包括实体框架工具和运行时的旧版本。This version of Visual Studio includes and older version of Entity Framework tools and runtime. 建议使用 Microsoft 下载中心中提供 的安装程序 Entity Framework Tools ef6.1.3 升级到。It is recommended that you upgrade to Entity Framework Tools 6.1.3, using the installer available in the Microsoft Download Center. 有关这些版本的详细信息,请参阅 以前的版本See Past Releases for more details on these releases.
  • 使用升级后的 EF 工具向新项目添加实体框架会自动添加 EF ef6.1.3 NuGet 包。Adding Entity Framework to new projects using the upgraded EF tools will automatically add the EF 6.1.3 NuGet package. 可以手动安装或升级到联机提供的任何 EF NuGet 包。You can manually install or upgrade to any EF NuGet package available online.
  • 默认情况下,此版本的 Visual Studio 中可用的 SQL Server 实例为 LocalDB 实例,名为 MSSQLLocalDB。By default, the SQL Server instance available with this version of Visual Studio is a LocalDB instance called MSSQLLocalDB. 应使用的连接字符串的服务器部分是 " (localdb) \ MSSQLLocalDB"。The server section of connection string you should use is "(localdb)\MSSQLLocalDB". @ \ \ 在 c # 代码中指定连接字符串时,请记住使用前缀为或双反斜杠 "" 的逐字字符串。Remember to use a verbatim string prefixed with @ or double back-slashes "\\" when specifying a connection string in C# code.

Visual Studio 2012Visual Studio 2012

  • 此版本的 Visual Studio 包括实体框架工具和运行时的旧版本。This version of Visual Studio includes and older version of Entity Framework tools and runtime. 建议使用 Microsoft 下载中心中提供 的安装程序 Entity Framework Tools ef6.1.3 升级到。It is recommended that you upgrade to Entity Framework Tools 6.1.3, using the installer available in the Microsoft Download Center. 有关这些版本的详细信息,请参阅 以前的版本See Past Releases for more details on these releases.
  • 使用升级后的 EF 工具向新项目添加实体框架会自动添加 EF ef6.1.3 NuGet 包。Adding Entity Framework to new projects using the upgraded EF tools will automatically add the EF 6.1.3 NuGet package. 可以手动安装或升级到联机提供的任何 EF NuGet 包。You can manually install or upgrade to any EF NuGet package available online.
  • 默认情况下,此版本的 Visual Studio 中可用的 SQL Server 实例是名为 "v 11.0" 的 LocalDB 实例。By default, the SQL Server instance available with this version of Visual Studio is a LocalDB instance called v11.0. 应使用的连接字符串的服务器部分是 " (localdb) \ v 11.0"。The server section of connection string you should use is "(localdb)\v11.0". @ \ \ 在 c # 代码中指定连接字符串时,请记住使用前缀为或双反斜杠 "" 的逐字字符串。Remember to use a verbatim string prefixed with @ or double back-slashes "\\" when specifying a connection string in C# code.

Visual Studio 2010Visual Studio 2010

  • 此版本的 Visual Studio 中提供的 Entity Framework Tools 版本与实体框架6运行时不兼容,因此无法升级。The version of Entity Framework Tools available with this version of Visual Studio is not compatible with the Entity Framework 6 runtime and cannot be upgraded.
  • 默认情况下,实体框架工具会将实体框架4.0 添加到你的项目。By default, the Entity Framework tools will add Entity Framework 4.0 to your projects. 若要使用任何更高版本的 EF 创建应用程序,首先需要安装 NuGet 包管理器扩展In order to create applications using any newer versions of EF, you will first need to install the NuGet Package Manager extension.
  • 默认情况下,EF 工具版本中的所有代码生成都基于 EntityObject 和实体框架4。By default, all code generation in the version of EF tools is based on EntityObject and Entity Framework 4. 建议通过安装适用于 c #Visual Basic的 DbContext 代码生成模板,将代码生成切换为基于 DbContext 和实体框架5。We recommend that you switch the code generation to be based on DbContext and Entity Framework 5, by installing the DbContext code generation templates for C# or Visual Basic.
  • 安装 NuGet 包管理器扩展后,可以手动安装或升级到任何联机可用的 EF NuGet 包,并将 EF6 与 Code First 一起使用,这不需要设计器。Once you have installed the NuGet Package Manager extensions, you can manually install or upgrade to any EF NuGet package available online and use EF6 with Code First, which does not require a designer.
  • 默认情况下,此版本的 Visual Studio 中提供的 SQL Server 实例 SQL Server Express 称为 SQLEXPRESS。By default, the SQL Server instance available with this version of Visual Studio is SQL Server Express named SQLEXPRESS. 应使用的连接字符串的服务器部分是 ""。 \SQLEXPRESS "。The server section of connection string you should use is ".\SQLEXPRESS". @ \ \ 在 c # 代码中指定连接字符串时,请记住使用前缀为或双反斜杠 "" 的逐字字符串。Remember to use a verbatim string prefixed with @ or double back-slashes "\\" when specifying a connection string in C# code.