Missing Entity Data Model in VS 2012

2019-07-05 14:00发布

I cannot find the Entity Data Model under the 'Data' tab when adding a new item.

I have looked at several questions and answers, information on this and none of the solutions have worked.

I have repaired, uninstalled and reinstalled, installed the EF Tools package manually and tried uninstalling all VS related programs. I have also tried creating several new projects, Class Libraries, Web Projects under different .NET frameworks and it isn't there.

Main project: Visual Studio 2012, Class Library Project .NET 4.0

4条回答
家丑人穷心不美
2楼-- · 2019-07-05 14:25

The new Entity Data Model in VS 2012 by default uses T4 templates (.tt) files instead of former custom tool for code generation. The generated context is also based newer DbContext API instead of ObjectContext API used by Visual Studio 2010 (that is the reason why it doesn't have the method - the equivalent method in DbContext API is Set<T>). Both T4 and DbContext API are currently recommended approach for using EF.

I don't have VS 2012 on my current machine but what you can try is to delete both .tt and turn on the old generation as described in .Desinger.cs.

Edit: You may try to Re-install VS2012 and/or repair it. That should fix this issue. In addition, look at the release version of your VS2012.

Another suggested solution to re-install and reason why this happens - Unable to add Entity data model to a Visual Studio project

查看更多
劫难
3楼-- · 2019-07-05 14:31

I updated Visual Studio 2012 using this link: http://www.microsoft.com/visualstudio/eng/downloads#d-visual-studio-2012-update. After this update, the "Entity Data Model" option was added to the data tab.

查看更多
欢心
4楼-- · 2019-07-05 14:35

You can right-click the designer surface and choose the model browser; Here is the only way to activate the Model browser in solution explorer. The Model browser is included in VS 2012 recommended settings during installation.

查看更多
做个烂人
5楼-- · 2019-07-05 14:37

The accepted answer from here solved the problem in my case:

http://www.datazx.cn/Fv7p5a/xw-US/oaax2pu/2q7xs6/d8x6rssc-b4mt-fsix-bc6c-ct8mf8d6fsbc23rsdfd.html

I finally figured it out. I ran EFTools.msi from a C:\ProgramData\Package Cache\ subfolder, which only allowed me to 'uninstall' or 'repair'. I tried repair, but I get the same problem, so I did 'uninstall', then ran it again and it allowed 'install'. After this install, I can now add Entity Data Models.

Also, the accepted answer in the "Missing Entity Framework Template in Visual Studio 2012 Express for Web" threat on forums.asp.net suggests that repairing Entity Framework Designer for Visual Studio 2012 enu via 'Start -> Control Panel -> Programs and Features' might work as well (I can post only two links with my current 1 point StackOverflow reputation, so I won't provide the exact source).

Another possible solution:

My Problem was: Visual Studio is installed on Drive D:\, whereas the Entity Framework Installer placed the Package in c:...\VisualStudio 10.0\Common7....\ItemTemplates folder. --> Copied the AdoNetEntityDataModelCSharp.zip to drive d: and ran devenv /installvstemplates. This fixxed it for me. Edit: Also had to copy Various DLLs from IDE folder, PrivateAssemblies and PublicAssemblies. then run devenv /ResetSkipPkgs

http://social.msdn.microsoft.com/Forums/en-US/c059069b-eae4-48b4-a06e-ffd5f186077b/adonet-data-entity-model-template-missing-in-vs-2010-ultimate?forum=adodotnetentityframework

I also installed VS in a non-default path (different disk partition), so it indeed may be one of the potential causes of the problem.

查看更多
登录 后发表回答