How can I resolve this error: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string

家住魔仙堡 提交于 2019-11-30 02:57:20

In VS 2012, the EF.Utility.CS.ttinclude file will only be installed if the Microsoft Web Developer Tools or Microsoft SQL Server Data Tools component is selected.

I had very similar issue and I tried with VS2012 and VS2013.

After reinstalling Entity Framework 6 Tools for Visual Studio 2012 http://www.microsoft.com/en-us/download/confirmation.aspx?id=40762 every thing went back to normal.

Reinstalling Entity Framework 6 Tools for Visual Studio 2012 http://www.microsoft.com/en-us/download/confirmation.aspx?id=40762 work for me

For VS2017, I ended up adding EF6.Utility.CS.ttinclude to model's folder. This resolved my issue with MySql and EF.

File can be found: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude

UPDATE To avoid doing the above, removing the entities completely then adding back in fixed the issue.

Visual Studio 2017

was getting the same error but only in a test project. after reviewing the test project and the other project successfully referencing that file i found that adding the following to the app.config of the failing project resolved my issue

  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
  <connectionStrings>

Had this issue with a recent install of VS2017 Enterprise after already having this functionality working in Professional.
The solution for me was to:

  1. Open the Visual Studio Installer program and "Modify" my Enterprise installation.
  2. Select "ASP.NET and web development" under the Web & Cloud section
  3. Click "Modify" in bottom right

It's probably worth noting that I already had EF6 installed and did not need to re-install it to get this to work.

After completing those steps and firing up Visual Studio, the error went away and I was able to generate my classes successfully. Hope this helps!

All of the above solutions did not work for me so I created a new project to see if the problem persists but the error did not occur in the newly created project. I then compared the project with the old backup to check recent changes made and found the problem. I recently had upgraded a package Clarius.TransformOnBuild to more recent version after downgrading the package the error went away.

In my case the issue was caused by a bizarre folder name (with %20 instead of spaces). I just made a directory junction to the same folder with spaces instead of %20 and it solved the issue.

Here is the PowerShell command I used to make the junction:

cd "c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\"
mklink /j "Entity Framework Tools" "Entity%20Framework%20Tools"
Junction created for Entity Framework Tools <<===>> Entity%20Framework%20Tools

You can then use ls look at the directory contents, and you should see these two lines (edited for brevity):

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
...
d----l        2/27/2019   9:57 AM                Entity Framework Tools
d-----        2/26/2019  12:24 PM                Entity%20Framework%20Tools
...

Under Mode, the l indicates that it is a "link" (aka junction), and the d indicates it's a directory. By making a junction instead of renaming the folder, you can be sure that both directory names will always work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!