1

Background

I got simple CRUD app using Entity Framework 6 created in Visual Studio 2017 Enterprise. Schema / models / DB stuff were created using *.edmx

Problem

After cloning reposiroty to different computer (or removing all of auto-generated *.cs files) while trying to build / rebuild I got following errors for every *.tt file:

Failed to resolve include text for file:[PATH TO APP DIRECTORY HERE]\EF6.Utility.CS.ttinclude.

Loading the include file 'EF6.Utility.CS.ttinclude' returned a null or empty string. The transformation will not be run.

Manual re-generation of files works fine (via opening popup menu on *.tt files and clicking Run Custom Tool)

This file exists in

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude

but I have absolutely no idea why VS is looking for it inside project path.

Is it a bug / problem with VS / EF6 configuration?

I've tried:

  • re-installation of Entity Framework Tools
  • adding 'ASP.NET and web development'

None of these helped :(

Similar thread:

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

Hardcoding correct path in auto-generated *.tt files IMO is not a proper solution

Mad Scientist
  • 331
  • 2
  • 15

1 Answers1

1

After follow Microsoft guide, I've added 'IncludeFolders' tag to resolve 'EF6.Utility.CS.ttinclude' and the 'ItemGroup' to invalidate DevEnvDir in template processing. This's how the .csproj file looks like:

...
<PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    <TransformOnBuild>True</TransformOnBuild>
    <TransformOutOfDateOnly>false</TransformOutOfDateOnly>
    <IncludeFolders>$(DevEnvDir)Extensions\Microsoft\Entity Framework Tools\Templates\Includes</IncludeFolders>
</PropertyGroup>
<ItemGroup>
    <T4ParameterValues Include="DevEnvDir">
        <Value>$(DevEnvDir)</Value>
        <Visible>False</Visible>
    </T4ParameterValues>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />
  • 1
    Welcome to StackOverflow! Can you explain modifications you did? – Alex Yu Mar 02 '19 at 17:37
  • After follow [Microsoft guide](https://learn.microsoft.com/en-us/visualstudio/modeling/code-generation-in-a-build-process?view=vs-2017#to-edit-the-project-file), I've added tag and the to invalidate DevEnvDir in template processing. – MarcoFernandezHeras Mar 02 '19 at 18:26
  • Ah. OK but it would be better if you edit your answer and include this explanation into it – Alex Yu Mar 02 '19 at 18:32