Reproduced:
http://www.cnblogs.com/Zhangzhigang/articles/4850549.html
1. Create a new. tt file
2. Open the. tt file
3. Paste in the following code (the path of the Inputfile file is modified according to the actual situation)
<#@ Template language="C #"debug="false"Hostspecific="true"#><#@ include file="EF6. Utility.CS.ttinclude"#><#@ Output Extension=". CS"#><# Const stringInputfile =@".. /MODEL/OUOA.EDMX"; varTexttransform = Dynamictexttransformation.create ( This); varCode =NewCodegenerationtools ( This); varEF =NewMetadatatools ( This); varFileManager = Entityframeworktemplatefilemanager.create ( This); Edmmetadataloader Loader=NewEdmmetadataloader (Texttransform.host, texttransform.errors); Edmitemcollection ItemCollection=(edmitemcollection) loader. Createedmitemcollection (Inputfile); //itemcollection.createedmitemcollection (inputfile); #>namespaceibll{<# foreach(EntityType entityinchItemcollection.getitems<entitytype> (). (E =e.name)) { #> Public Partial InterfaceI<#=entity. Name#>bll:ibasebll<model.<#=entity. Name#>> { }<#}#>}<#+ Public Static voidArgumentnotnull<t> (T Arg,stringNamewhereT:class{ if(arg = =NULL) { Throw NewArgumentNullException (name); }}#>
4.
Use of the T4 template for C #------Entity FRAMEWORK6