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

StackOverflow https://stackoverflow.com/questions/14999633

Pregunta

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 expected range.

Tools Used: VS 2012, Entity Framework 5.0.0, T4MVCExtensions 3.5.0, .NET Framework 4.5

I've been using EF and T4 templates in a project within a large MVC solution without incident. Now, when I right-click on the edmx diagram, EF responds with the message: Value does not fall within the expected range. When I compile the EF project it responds with these messages:

  1. Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string. The transformation will not be run. C:\Projects\NSAForms\NSAForms\NSAFormsEDM\NSAFormsEntities.tt
  2. Failed to resolve include text for file:C:\Projects\NSAForms\NSAForms\NSAFormsEDM\EF.Utility.CS.ttinclude C:\Projects\NSAForms\NSAForms\NSAFormsEDM\NSAFormsEntities.tt

Every table in the database has a primary key. I'm struck by how suddenly this issue appeared. Does anyone have some suggestions how to resolve this issue?

Thanks in advance,

Arnold

¿Fue útil?

Solución 2

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.

Otros consejos

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 enter image description here

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top