在 VS2017 中找不到 ADO.net 实体数据模型模板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44299332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:56:04  来源:igfitidea点击:

Can't find ADO.net Entity Data Model template in VS2017

.netasp.net-mvcentity-frameworkmodel-view-controllervisual-studio-2017

提问by Sandaru

I was trying to create an ASP.NET MVC web application in Visual Studio 2017. I need to take an EF database-first approach for the work.

我试图在 Visual Studio 2017 中创建一个 ASP.NET MVC Web 应用程序。我需要采用 EF 数据库优先的方法来完成这项工作。

Unfortunately I can't find the ADO.NET Entity Data Model template in my "Data" template folder:

不幸的是,我在“数据”模板文件夹中找不到 ADO.NET 实体数据模型模板:

enter image description here

在此处输入图片说明

I have tried following suggestions which didn't work for me.

我尝试了以下对我不起作用的建议。

  1. Installing Entity Framework 6.x via NuGet
  2. Installing package manually by double clicking latest msi file
  3. Changing .NET version from 4.6.x to 3.5
  1. 通过 NuGet 安装实体框架 6.x
  2. 通过双击最新的 msi 文件手动安装包
  3. 将 .NET 版本从 4.6.x 更改为 3.5

NOTE: I have VS 2015 and VS 2017 both installed on my machine. Only VS 2017 has the problem.

注意:我的机器上安装了 VS 2015 和 VS 2017。只有 VS 2017 有问题。

I have created the ASP.NET MVC project as follows:

我创建了 ASP.NET MVC 项目如下:

File -> New -> Project -> Web -> ASP.NET Web Application (.NET Framework) -> MVC

Does anyone know a solution for this problem?

有谁知道这个问题的解决方案?

回答by gopinath s

  1. Go to Tools -> Get Tools and features
  2. Select Individual components tab and check Entity Framework 6 tools under SDK's, libraries, and framework section
  1. 转到工具 -> 获取工具和功能
  2. 选择单个组件选项卡并检查 SDK's、libraries 和 framework 部分下的 Entity Framework 6 工具

回答by M.Reza

It seems you added "Class Library (.NET Standard)" which is not supporting ADO.net Entity Data Model. You may add "Class Library (.NET Framework)"

您似乎添加了不支持 ADO.net 实体数据模型的“类库(.NET 标准)”。您可以添加“类库(.NET 框架)”

回答by dapug

For those of you trying the other solutions and still not seeing the templates...

对于那些尝试其他解决方案但仍然看不到模板的人...

Perhaps you are attempting to add ADO EF to a .NET Core 2.0 project, and EF is not supported out of the box.

也许您正在尝试将 ADO EF 添加到.NET Core 2.0 项目,并且不支持 EF 开箱即用

You have 2 options:

您有 2 个选择:

  1. Install Core 2.0 SDK and NuGet that is aware of .NET Standard 2.0
  2. Use a .NET 4.x project rather than Core
  1. 安装支持 .NET Standard 2.0 的 Core 2.0 SDK 和 NuGet
  2. 使用 .NET 4.x 项目而不是 Core

I recommend #1. VS 2017 doesn't actually have the full Core 2.0 SDK installed, nor is it available from the VS installer(which many comments here struggle with).

我推荐#1。VS 2017 实际上并没有安装完整的 Core 2.0 SDK,也没有从 VS 安装程序中获得它(这里有很多评论都在争论)。

I know, confusing, right?

我知道,令人困惑,对吧?

From Microsoft:

来自微软:

"You will need to download and install a version of the .NET Core 2.0 SDK that is appropriate to your platform. This is true even if you have installed Visual Studio 2017 version 15.3."

“您需要下载并安装适合您平台的 .NET Core 2.0 SDK 版本。即使您已安装 Visual Studio 2017 版本 15.3,也是如此。”

"In order to use EF Core 2.0 or any other .NET Standard 2.0 library with a .NET platforms besides .NET Core 2.0 (e.g. with .NET Framework 4.6.1 or greater) you will need a version of NuGet that is aware of the .NET Standard 2.0 and its compatible frameworks"

“为了在 .NET Core 2.0 之外的 .NET 平台上使用 EF Core 2.0 或任何其他 .NET Standard 2.0 库(例如,使用 .NET Framework 4.6.1 或更高版本),您需要一个知道.NET Standard 2.0 及其兼容框架”

https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-entity-framework-core-2-0/

https://blogs.msdn.microsoft.com/dotnet/2017/08/14/annoucing-entity-framework-core-2-0/

Now... got all that installed and still not seeing the ADO template? I believe that is because it is deprecated/obsolete. This is the way to get EF working in .NET Core: https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

现在...安装了所有这些,但仍然没有看到 ADO 模板?我相信这是因为它已被弃用/过时。这是让 EF 在 .NET Core 中工作的方法:https: //docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

Hope this helps! You're welcome.

希望这可以帮助!别客气。

回答by Dan Leksell

I had to create a new project using .Net 4.5.2 then I was able to add the ADO.NET Entity Data Model.

我必须使用 .Net 4.5.2 创建一个新项目,然后才能添加 ADO.NET 实体数据模型。

  1. File -> New Project
  2. Select Web -> ASP.NET Web Application (.NET Framework)
  3. Set Framework at bottom of window to .NET Framework 4.5.2 enter image description here
  4. Use Empty Template enter image description here
  5. Right click project (not your solution) -> Add -> New Item
  6. Select Data -> ADO.NET Entity Data Model enter image description here
  1. 文件 -> 新建项目
  2. 选择 Web -> ASP.NET Web 应用程序(.NET Framework)
  3. 将窗口底部的 Framework 设置为 .NET Framework 4.5.2 在此处输入图片说明
  4. 使用空模板 在此处输入图片说明
  5. 右键单击项目(不是您的解决方案)-> 添加-> 新建项目
  6. 选择数据 -> ADO.NET 实体数据模型 在此处输入图片说明

回答by Abror

Not a solution as such, but check that the project you've added is for .NET Framework and not .NET Standard. The templates for adding things such as ADO.NET Entity Data Model are included for .NET Framework.

不是这样的解决方案,但请检查您添加的项目是否适用于 .NET Framework 而不是 .NET Standard。.NET Framework 包含用于添加 ADO.NET 实体数据模型等内容的模板。

回答by Sandeep Chary Tipparti

Tools-->Click Get Tools and Features-->Click on Modify--> Click on Individual components--> Tick the CheckBox of Entity Framework 6 Tools -->click on Modify--> You'll get a pop up window-->click on Retry(if it not closed, Click on Continue)

工具-->点击获取工具和功能-->点击修改-->点击单个组件-->勾选实体框架6工具的复选框-->点击Modify-->你会得到一个弹出窗口- ->点击重试(如果没有关闭,点击继续

Now Launch VS and this time check in Data ADO.NET Entity Modelwill be added.

现在启动 VS,这次检查数据ADO.NET 实体模型将被添加。

Please Check this Article http://dotnet-jigyasa.blogspot.com/2018/03/adonet-entity-data-model-missing-visual.htmlWorked for me.

请查看这篇文章 http://dotnet-jigyasa.blogspot.com/2018/03/adonet-entity-data-model-missing-visual.html对我来说有效。

回答by shakeeb

i think you selected class library (.NET Standard) instead of class library (.NET framework), try to select class library (.NET framework) you will get it.

我认为您选择了类库(.NET Standard)而不是类库(.NET 框架),尝试选择类库(.NET 框架)您会得到它。

回答by Bappa Aditya Shee

Basically what I found is when you choose .Net Core Project EF not shown under data tab. You need to choose .Net Framework Instead of .Net Core. Then you will find all the stuffs under data tab.

基本上我发现的是当您选择 .Net Core Project EF 时未显示在数据选项卡下。您需要选择 .Net Framework 而不是 .Net Core。然后你会在数据选项卡下找到所有的东西。

回答by sas

I was having the same problem in VS2017 Community Edition. I had previously tried following but none worked:

我在 VS2017 社区版中遇到了同样的问题。我以前尝试过以下但没有奏效:

  • Installed new feature for "SQL Server Data Tools".
  • Installed NuGet Libraries.
  • 为“SQL Server Data Tools”安装了新功能。
  • 已安装 NuGet 库。

In the end upon closer investigation I had targeted the wrong
See Image: you should be selected .NET Framework instead of .NET Standard

最后,经过仔细调查,我的目标是错误的,
请参见图片:您应该选择 .NET Framework 而不是 .NET Standard

For me changed to the correct project type while Targeting ".NET framework" instead of ".NET Standard" worked.

对我来说,在 Targeting ".NET framework" 而不是 ".NET Standard" 工作时更改为正确的项目类型。

回答by Piyumali Adhikari

To solve above problem you can modify Visual Studio 2017.You can follow these steps.

要解决上述问题,您可以修改 Visual Studio 2017。您可以按照以下步骤操作。

  1. Go to Control Panel\Programs\Programs and Features of your computer.

  2. Select Microsoft Visual Studio 2017, right click on it and change.

  3. It will goes to Visual Studio Products window and now click on modify button.

  4. Now tick ASP.Net and web development workload in Web & Cloud section and modify it.

  5. Finally launch Visual Studio 2017.

  1. 转到计算机的控制面板\程序\程序和功能。

  2. 选择Microsoft Visual Studio 2017,右键单击并更改。

  3. 它将转到 Visual Studio 产品窗口,然后单击修改按钮。

  4. 现在在 Web & Cloud 部分勾选 ASP.Net 和 Web 开发工作负载并修改它。

  5. 最后启动 Visual Studio 2017。