不过我试了下没解决太麻烦了 而且一旦EF要重新生成又的重新弄。

后来我查询 了一下资料,可以运用T4模板来解决这个问题。

1.  下载文件GetSummery.ttinclude,这里我提供了,大家去下载:下载

2.  把我们下载下来的文件解压,将解压出来的文件放入解决方案中

3. 修改下app.config,添加一个连接字符串:

[html] view plain copy
 
  1. <add name="MyConn" connectionString="data source=.;initial catalog=db;user id=sa;password=xxx;" providerName="System.Data.SqlClient" />   

4.  修改model.tt,在顶部位置加入代码:

 

[html] view plain copy
 
  1. <#@ include file="GetSummery.ttinclude"#>  

 5. (插入类注释,可以选择添加)在代码片段<#=codeStringGenerator.EntityClassOpening(entity)#>的上方(28行左右)插入

 

[html] view plain copy
 
  1. /// <summary>  
  2. /// <#= getTableSummery(code.Escape(entity)) #>  
  3. /// </summary>  

 

6. (添加字段注释)在代码片段:<#=codeStringGenerator.Property(edmProperty)#>的上方(76行左右)插入:

[html] view plain copy
 
  1. /// <summary>  
  2. /// <#= getColumnSummery(code.Escape(entity),code.Escape(edmProperty)) #>  
  3. /// </summary>  

 

注意:前面的注释符号///不能少

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

posted on 2017-11-21 23:53  一本正经。胡说9道  阅读(150)  评论(0)    收藏  举报