簡體   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