Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have added information into the Documentation.Summary property in the graphical editor but that's not being added to the generated classes. Is there any way to do this?

like image 722
Rob Church Avatar asked Jan 03 '13 16:01

Rob Church


1 Answers

I found the answer to this was to alter the T4 template (.tt file in solution). This is responsible for generating the C# class code. Find any place where you want summary information added (such as before each simple property that is written out). So for example, here is the altered code for the simple properties:

<#
if (simpleProperties.Any()) {
    foreach (var edmProperty in simpleProperties) {
        if (edmProperty.Documentation != null) {
#>
    ///<summary><#=edmProperty.Documentation.Summary #></summary>
<#
        }
#>
    <#=codeStringGenerator.Property(edmProperty)#>
<#
    }
}
#>
like image 107
Rob Church Avatar answered Nov 05 '22 03:11

Rob Church