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

后端 未结 8 2073
再見小時候
再見小時候 2020-12-28 15:07

How can I resolve these errors:

  1. Loading the include file \'EF.Utility.CS.ttinclude\' returned a null or empty string.
  2. Value does not fall within the
相关标签:
8条回答
  • 2020-12-28 15:48

    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>
    
    0 讨论(0)
  • 2020-12-28 15:48

    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.

    0 讨论(0)
  • 2020-12-28 15:50

    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.

    0 讨论(0)
  • 2020-12-28 15:56

    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.

    0 讨论(0)
  • 2020-12-28 15:56

    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.

    0 讨论(0)
  • 2020-12-28 15:59

    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!

    0 讨论(0)
提交回复
热议问题