i have the habbit to comment properties and classes with the standard XML documentation, what it means / what they do.
But in EF generated classes off course, these are all gone when i regenerate the model.
Is there another way to do this?
C# documentation comments use XML elements to define the structure of the output documentation. One consequence of this feature is that you can add any valid XML in your documentation comments. The C# compiler copies these elements into the output XML file.
The only way I know to do this is on the line right above your method just type "///" and it will generate a comment template based on the method.
Single-line comments The most basic type of comment in C# is the single-line comment. As the name indicates, it turns a single line into a comment - let's see how it might look: // My comments about the class name could go here... // My comments about the class name could go here...
A comment is preceded by an double forward slash. The code of line after the double forward slash is simply ignored by the compiler. To code a comment, type an double forward slash followed by the comment. You can use this technique to add a comment on its own line or to add a comment after the code on a line.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With