visual-studio 如何创建实体框架项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3919026/
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
How to Create a Entity Framework Project?
提问by Vaccano
OK, so I feel dumb for asking this... but I am stumped.
好吧,所以我觉得问这个很愚蠢......但我很难过。
I can't seem to create a project/unit for using the ADO.NET Entity Framework.
我似乎无法为使用 ADO.NET 实体框架创建项目/单元。
I looked for a project type that looked like it would match, but no go (closest I could find was ASP.NET Dynamic Data Entities Web Application).
我寻找了一个看起来很匹配的项目类型,但没有找到(我能找到的最接近的是 ASP.NET 动态数据实体 Web 应用程序)。
I also tried to just add a unit (like you do for Linq-to-SQL). But I could not find anything "Entity Framework"y to add (though Linq-to-SQL is in the list). (Note: I tried adding it to a normal Class Library and to a WCF Project.)
我还尝试只添加一个单元(就像您为 Linq-to-SQL 所做的那样)。但是我找不到任何要添加的“实体框架”(尽管 Linq-to-SQL 在列表中)。(注意:我尝试将其添加到普通类库和 WCF 项目中。)
Is there something I need to download? Is there an anti-stupid pill I need to take? ('cause I feel stupid for not being able to figure this out)
有什么我需要下载的吗?有我需要服用的抗愚蠢药吗?(因为我无法弄清楚这一点,我感到很愚蠢)
(I am using Visual Studio 2010 Ultimate connecting to SQL Server 2008)
(我使用 Visual Studio 2010 Ultimate 连接到 SQL Server 2008)
Here is a screen shot of my Add New Item window:
这是我的“添加新项目”窗口的屏幕截图:


I got this by right clicking on a Class Library Project and select Add New Item. There is no Entity Framework in it.
我通过右键单击类库项目并选择添加新项目来获得此信息。其中没有实体框架。
回答by Henk Holterman
Begin with any Project (like a ClassLibrary) and Add an EF model.
从任何项目(如 ClassLibrary)开始并添加 EF 模型。
There should be a "ADO.NET Entity Data Model" item in your "Add New Item" dialog.
在“添加新项目”对话框中应该有一个“ADO.NET 实体数据模型”项目。
回答by Robert Harvey
In the Solution Explorer, Right-click, Add New Item.
Select ADO.NET Entity Data Modelin the Templates pane.
Give it a name, and click the Addbutton.
在解决方案资源管理器中,右键单击,添加新项。
在模板窗格中选择ADO.NET 实体数据模型。
为其命名,然后单击“添加”按钮。
回答by user2063329
I see the item Data in installed templates in your image. Right click that to open the data related templates. he entity frame work related templates should be there.
我在您的图像中看到已安装模板中的项目数据。右键单击以打开数据相关模板。实体框架相关的模板应该在那里。
回答by dmcghee99306
The ADO.NET entity frame work data model project that you are referring to is actually an 'item' that must be added to an existing visual studio project. Reference: https://msdn.microsoft.com/en-us/library/jj206878(v=vs.113).aspx
您所指的 ADO.NET 实体框架工作数据模型项目实际上是一个必须添加到现有 Visual Studio 项目中的“项目”。参考:https: //msdn.microsoft.com/en-us/library/jj206878(v=vs.113).aspx
If you create a class library and attempt to add a new item to it, then the ADO.NEW entity frame work data model 'item' will be available for addition to your class library or 'project'. Add Entity Frame Work Item to existing Project or Class Library
如果您创建类库并尝试向其中添加新项目,则 ADO.NEW 实体框架工作数据模型“项目”将可用于添加到您的类库或“项目”。 将实体框架工作项添加到现有项目或类库
回答by Andrew
This just happened to me, but it was because I mistakenly created a Class Library (.NET Standard), which uses .NET 2.0. As soon as I created a Class Library (.NET Framework), I was able to add an Entity Framework file by choosing ADO.NET Entity Data Model.
这只是发生在我身上,但这是因为我错误地创建了一个使用 .NET 2.0的类库 (.NET Standard)。一旦我创建了一个类库 (.NET Framework),我就能够通过选择ADO.NET 实体数据模型来添加一个实体框架文件。

