繁体   English   中英

在使用Model-First方法时,如何将XML注释添加到Entity Framework生成的自动生成的类中?

[英]How do I add XML comments to the auto-generated classes produced by Entity Framework when using Model-First approach?

我已将信息添加到图形编辑器中的Documentation.Summary属性中,但未将其添加到生成的类中。 有没有办法做到这一点?

我发现答案是改变T4模板(解决方案中的.tt文件)。 这负责生成C#类代码。 找到您想要添加摘要信息的任何位置(例如在写出的每个简单属性之前)。 例如,以下是简单属性的更改代码:

<#
if (simpleProperties.Any()) {
    foreach (var edmProperty in simpleProperties) {
        if (edmProperty.Documentation != null) {
#>
    ///<summary><#=edmProperty.Documentation.Summary #></summary>
<#
        }
#>
    <#=codeStringGenerator.Property(edmProperty)#>
<#
    }
}
#>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM