T4 simple template

下载

http://t4-editor.tangible-engineering.com/Download_T4Editor_Plus_ModelingTools.html

添加新建项Simple T4 Template,生成IBLL,注意不是添加运行时文本模板

<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#> 
 <#
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, 1);
MetadataTools ef = new MetadataTools(this);

string inputFile = @"..ModelModel.edmx";

EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
string namespaceName = code.VsNamespaceSuggestion();

EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);

#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace IBLL
{
<#

// Emit Entity Types
foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name))
{
    //fileManager.StartNewFile(entity.Name + "RepositoryExt.cs");
    //BeginNamespace(namespaceName, code);
    
#>
    public partial interface I<#=entity.Name#>BLL : IBaseBLL<Model.<#=entity.Name#>>
    {
    
    }

<#}#>

}
原文地址:https://www.cnblogs.com/tgdjw/p/4673204.html