2017-04-12 54 views
2

在實體框架爲我的實體創建的.tt文件和DbContext世代中,我看到類使用如TypeMapperAccessibility。這些類型在哪裏定義,並在任何地方記錄?我想定製我的t4模板,但很難知道這些類中的任何一個是如何使用它們的。定義實體框架T4模板中使用的類型在哪裏?

回答

2

實體框架T4模板具有包括文件頂部的指令。對於C#,它看起來像:

<#@ include file="EF6.Utility.CS.ttinclude"#> 

此文件可以在Visual Studio IDE擴展文件夾中找到。例如。默認情況下爲Visual Studio 2017年將是:

C:\ Program Files文件(x86)的\微軟的Visual Studio \ 2017年\社區\ Common7 \ IDE \擴展\微軟\實體 框架工具\模板\包括\

該文件包含用於實體生成的助手類。例如。

/// <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 

第二類TypeMapper在上下文生成模板本身中定義。

+0

謝謝。對於Visual Studio 2013,它位於 'C:\ Program Files(x86)\ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ Extensions \ Microsoft \ Entity Framework Tools \ Templates \ Includes' – xr280xr