I'd like to add more details to Matt Mhetton's answer because because of my current project configuration (CA and Style cop) everything MUST be documented..
On the one hand you will have to add documentation properties in the designer for everything you want to document (classes, simple properties, complex properties and navigation properties)
On the other hand you have to open WhateverModel.tt you havecreated and edit it to contain documentation, I explain it step by step:
1.- For class documentation, look for:
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
<#=codeStringGenerator.EntityClassOpening(entity)#>
(line 26 in my case) and place your comments just between those two lines like this:
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
<# if (entity != null && entity.Documentation != null) {#>
/// <summary>
/// <#= entity.Documentation.Summary #>
/// </summary>
<# } #>
<#=codeStringGenerator.EntityClassOpening(entity)#>
2.- For constructor documentation look for public <#=code.Escape(entity)#>()
thaqt's what generates the constructor so place your documentation just before that line like this:
<# if (entity != null && entity.Documentation != null) {#>
/// <summary>
/// <#= entity.Documentation.Summary #>
/// </summary>
<# } #>
public <#=code.Escape(entity)#>()
{
3.- To document every property look for foreach (var edmProperty in simpleProperties)
, this look is the one that will generate properties code so, it should looks like this:
foreach (var edmProperty in simpleProperties)
{
#>
<# if (edmProperty != null && edmProperty.Documentation != null) {#>
/// <summary>
/// <#= edmProperty.Documentation.Summary #>
/// </summary>
<# } #>
<#=codeStringGenerator.Property(edmProperty)#>
<#
}
(NOTE: that's for simple properties but is going to be3 the same way for complex properties...)
4.- For navigation properties exactly the same, look for foreach (var navigationProperty in navigationProperties)
and add your documentation like this:
foreach (var navigationProperty in navigationProperties)
{
#>
<# if (navigationProperty != null && navigationProperty.Documentation != null) {#>
/// <summary>
/// <#= navigationProperty.Documentation.Summary #>
/// </summary>
<# } #>
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
<#
}
4.- Last but not least, if you also need documentation in your context class you could use this (look for <# if (code.Escape(container) != null) {#>
):
<# if (code.Escape(container) != null) {#>
/// <summary>
/// Represents <#= code.Escape(container) #>
/// </summary>
<# } #>
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
{
<# if (code.Escape(container) != null) {#>
/// <summary>
/// Initializes a new instance of the <see cref="<#= code.Escape(container) #>"/> class.
/// </summary>
<# } #>
public <#=code.Escape(container)#>()
: base("name=<#=container.Name#>")
{
<#
if (!loader.IsLazyLoadingEnabled(container))
{
#>
this.Configuration.LazyLoadingEnabled = false;
<#
}
#>
}
/// <summary>
/// On Model Creating
/// </summary>
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
<#
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
{
#>
<# if (code.Escape(entitySet) != null) {#>
/// <summary>
/// Gets or sets the <#=code.Escape(entitySet)#>
/// </summary>
<# } #>
I hope it helps like Matt Whetton's answer helped me (thank you Matt).