添加XML文档/注释性能/ EF的领域生成的类 [英] Add XML documentation / comments to properties/fields in EF generated classes
问题描述
我有习惯中与标准的XML文档的评论属性和类,这意味着什么,他们做的/什么。
i have the habbit to comment properties and classes with the standard XML documentation, what it means / what they do.
但在EF生成的类关当然,这些是当我重新生成模型都没有了。
But in EF generated classes off course, these are all gone when i regenerate the model.
有另一种方式来做到这一点?
Is there another way to do this?
推荐答案
由于在拉吉斯拉夫他的回答说,你需要修改T4模板,这样的评论将被包含在生成的代码。这个答案是从这篇文章:
As Ladislav stated in his answer, you need to modify the T4 template so the comments will be included in the generated code. This answer was taken from this article:
所有你需要在模型设计器的属性框指定您的意见第一。 。在文档 - >详细描述和总结
First of all you need to specify your comments in the properties boxes of the model designer. Under Documentation -> Long Description, and Summary.
然后在模板中,例如,您可以添加此要记录的属性上面:
Then in the template, you can for example add this above the property you want to document:
<#if (!ReferenceEquals(edmProperty.Documentation, null))
{
#>
/// <summary>
/// <#=edmProperty.Documentation.Summary#> – <#=edmProperty.Documentation.LongDescription#>
/// </summary>
<#}#>
这将创建生成的代码你的财产之上的总结块。
This will create a summary block above your property in the generated code.
这篇关于添加XML文档/注释性能/ EF的领域生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!