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

8

30

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

Fiddlewood answered 21/2, 2013 at 10:14 Comment(9)
This sounds less like a db issue and more like a code/solution issue - Do you work in a team and synchronise through source control? Is it possible someone has failed to check a new file in? Does anyone else experience these issues? Does reverting to earlier versions of your code resolve the issue? If so, is it possible to identify the problem changeset and do a diff?Metallophone
@Basic. I reverted back to a deployed version dated 2/15/2013. All the files are there. Still getting the 'EF.Utility.CS.ttinclude' error on a compile. Still can't right-click on the edmx designer without getting: Value does not fall within the expected range. ThanksFiddlewood
I created a totally new project and added EF. Getting the very same errors.Fiddlewood
Interesting - Have you already seen this answer? It implies that you might need the VS2012 SDK. I admit I don't know what the problem is and am guessing but if I were you, I'd first do a repair install of VS2012 then try installing the SDK. Is it possible you've got any extensions which are interfering?Metallophone
When I right-click in the new project I sometimes see a different error: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))Fiddlewood
I repaired the VS2012 install and then reinstalled the SDK. I've tried pointing to other databases, but still the same errors.Fiddlewood
How can I find out what is making 'EF.Utility.CS.ttinclude' throw the error when compiling? Thanks.Fiddlewood
You could configure your build to add the /verbosity:diag option which should give you mountains of info. (MsBuild command line reference). You could also use Fusion which monitors and reports on all attempts by the framework to load asemblies (You'd normally use this on your compiled exe but you might be able to get away with running it against msbuild/devenv to see what they're trying to do but I must admit I've never tried it)Metallophone
Oh and if you'd care to share a minimal test solution, I'd be happy to load it up in my VS and see if I can replicate the issueMetallophone
O
28

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.

Oran answered 22/2, 2013 at 0:31 Comment(8)
+1 Good info but could you consider including a link for further reading?Metallophone
@Metallophone Unfortunately, the only links I have are a comment on our blog, and a discussion on CodePlex. I'll bring it up to the team again to see if we can get it somewhere a little more obvious like the Get It page.Oran
@Basic. Thanks for asking Brice for more information and explanation. I've spent too much precious work time chasing down scraps of documentation. By the time I'd gotten back to Stack to see Brice's answer, I'd already started implementing Telerik's ORM with zero problems. I haven't tested yet, but what a nice change it was to work with a tool that didn't depend upon other unknown (to me) library.Fiddlewood
Selected at installation time? Selected when and where?Fabled
@Fabled Yes, during install. If you've already installed, select the program in Programs and Features (or Add/Remove Programs), click Change, then click Modify.Oran
@Oran how ab installing in NUGET ? how do i add to source controller ?Butyrate
I installed both but still issueBarker
Regarding the original post: the solution is to install the Entity Framework 6 Tools as part of the Visual Studio install (Individual Components section).Clarey
L
70

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.

Lemberg answered 13/11, 2013 at 18:44 Comment(7)
how do u add it to source control ?? you will install in every machine ?Butyrate
I had installed EF6 update 6.1.1 and was wondering why I had this error until I found your comment. Tools must be upgraded to be same version as EF6 libraries. The error I had was: Error 168 "The provider did not return a ProviderManifest instance. Could not determine store version; a valid store connection or a version hint is required." Thanks for your help.Chewink
I wish I could +9999999 this. What a headache! Thanks a ton!Sporogenesis
I had this error in VS2012 with EF6 (a colleague had started the project in VS2013). The error text was failed to resolve include text EF_6_.Utility.CS.ttinclude. Installing these EF 6 Tools for VS2012 solved the problem.Ignazio
Didn't fix it for me. My nightmare goes on.Chandlery
Microsoft ... just say no.Ambiguity
still issue for meBarker
O
28

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.

Oran answered 22/2, 2013 at 0:31 Comment(8)
+1 Good info but could you consider including a link for further reading?Metallophone
@Metallophone Unfortunately, the only links I have are a comment on our blog, and a discussion on CodePlex. I'll bring it up to the team again to see if we can get it somewhere a little more obvious like the Get It page.Oran
@Basic. Thanks for asking Brice for more information and explanation. I've spent too much precious work time chasing down scraps of documentation. By the time I'd gotten back to Stack to see Brice's answer, I'd already started implementing Telerik's ORM with zero problems. I haven't tested yet, but what a nice change it was to work with a tool that didn't depend upon other unknown (to me) library.Fiddlewood
Selected at installation time? Selected when and where?Fabled
@Fabled Yes, during install. If you've already installed, select the program in Programs and Features (or Add/Remove Programs), click Change, then click Modify.Oran
@Oran how ab installing in NUGET ? how do i add to source controller ?Butyrate
I installed both but still issueBarker
Regarding the original post: the solution is to install the Entity Framework 6 Tools as part of the Visual Studio install (Individual Components section).Clarey
W
5

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

Wristlet answered 9/11, 2015 at 15:55 Comment(1)
still issue for meBarker
A
2

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.

Albemarle answered 25/4, 2017 at 17:42 Comment(2)
Copying included files to every project doesn't seem to be good practice and valid solutionCabin
@MadScientist agreed. updated with a solution that seems to work better.Albemarle
V
2

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!

Vicarious answered 2/4, 2018 at 18:1 Comment(0)
M
0

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>
Moke answered 18/9, 2017 at 15:53 Comment(0)
P
0

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.

Pincer answered 30/1, 2019 at 6:4 Comment(2)
What version did you downgrade to? I've just added this package, and am now experiencing this error.Grab
Clarius.TransformOnBuild Version 1.1.12Pincer
D
0

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.

Debidebilitate answered 11/7, 2019 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.