标签:creat space file orderby 技术 分享 type tput nbsp
转载:
http://www.cnblogs.com/Zhangzhigang/articles/4850549.html
1.新建一个.tt文件
2.打开.tt文件
3.粘贴入以下代码即可(inputFile文件的路径根据实际情况进行修改)
<#@ template language="C#" debug="false" hostspecific="true"#> <#@ include file="EF6.Utility.CS.ttinclude"#><#@ output extension=".cs"#><# const string inputFile = @"../MODEL/OuOA.edmx"; var textTransform = DynamicTextTransformation.Create(this); var code = new CodeGenerationTools(this); var ef = new MetadataTools(this); var fileManager = EntityFrameworkTemplateFileManager.Create(this); EdmMetadataLoader loader=new EdmMetadataLoader(textTransform.Host, textTransform.Errors); EdmItemCollection itemCollection = (EdmItemCollection)loader.CreateEdmItemCollection(inputFile); //itemCollection.CreateEdmItemCollection(inputFile); #> namespace IBLL { <# foreach(EntityType entity in itemCollection.GetItems<EntityType>().OrderBy(e => e.Name)) { #> public partial interface I<#=entity.Name#>BLL : IBaseBLL<MODEL.<#=entity.Name#>> { } <#}#> } <#+ public static void ArgumentNotNull<T>(T arg, string name) where T : class { if (arg == null) { throw new ArgumentNullException(name); } } #>
4.效果图
C#------Entity Framework6的T4模板的使用
标签:creat space file orderby 技术 分享 type tput nbsp
原文地址:http://www.cnblogs.com/tianhengblogs/p/7242545.html