时间:2021-07-01 10:21:17 帮助过:2人阅读
然后我们修改model.tt,在顶部位置加入代码:
| 1 | <#@ include file="GetSummery.ttinclude"#> | 
加入的位置如图:

紧接着在模板中查找代码片段<#=codeStringGenerator.UsingDirectives(inHeader: false)#>的位置,在代码下插入:
| 1 2 3 | /// <summary> /// <#= getTableSummery(code.Escape(entity)) #> /// </summary> | 
继续查找代码片段:<#=codeStringGenerator.Property(edmProperty)#>的位置,在代码上方插入:
| 1 2 3 | /// <summary> /// <#= getColumnSummery(code.Escape(entity),code.Escape(edmProperty)) #> /// </summary> | 
注意:前面的注释符号///不能少
这里放出一个我的截图,方便大家对照行号,确定大概位置:

到这里,就基本上完成了,去刷新一下你的实体模型edmx文件,你会发现字段的注释都自动加上去了。

本文转载至:http://jeffblog.sinaapp.com/archives/501
使用T4模板为EF框架添加实体根据数据库自动生成字段注释的功能
标签: