In the .tt
files created by Entity Framework for my entities and DbContext
generation, I see classes like TypeMapper
and Accessibility
used. Where are these types defined and are they documented anywhere? I want to customize my t4 templates, but it's difficult not knowing what any of these classes do or how to use them.
Entity Framework T4 template has include directive at the top of the file. For C# it will look like:
<#@ include file="EF6.Utility.CS.ttinclude"#>
This file can be found in Visual Studio IDE extensions folder. E.g. by default for Visual Studio 2017 it will be:
c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\
This file contains helper classes which are used for entities generation. E.g.
/// <summary>
/// Responsible for encapsulating the retrieval and translation of the CodeGeneration
/// annotations in the EntityFramework Metadata to form that is useful in code generation.
/// </summary>
public static class Accessibility
Second class TypeMapper
is defined in the context generation template itself.