Where are types used in Entity Framework T4 templates defined?

entity-framework entity-framework-6 t4

Question

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.

1
2
4/13/2017 4:55:17 AM

Accepted Answer

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.

3
4/12/2017 11:46:08 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow