• Post Calendar

    January 2010
    S M T W T F S
    « Nov   Feb »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  

XML Comments for Entity Framework

Technorati Tags: ,,,

HEADLINE: If I use the Entity Framework (Self Tracking Entities or EntityObjects) templates, how can I add XML Comments so that I can use Sandcastle and Sandcastle Help File Builder to generate the documentation for my libraries? Is there a way to modify the T4 templates so that I can access the property documentation? (The answer is yes)

This uses Microsoft Visual Studio 2010 Beta 2, Microsoft ADO.NET Entity Framework (EF) Feature Community Technology Preview 2, Sandcastle, and Sandcastle Help File Builder (SHFB)

Details:

If I turn on XML Documentation:

image

Then a comment like this:

Code Snippet
  1. /// <summary>
  2. /// Represents a book in the library.
  3. /// </summary>
  4. public partial class Book

Will be output into the .xml file.

I tried putting documentation into the Model. Here is the designer view:

clip_image004

However, these never seem to be output as the publicly visible comments (///) in the generated code.

To do that, add this in the template immediately above the property:

Code Snippet
  1. <#if (!ReferenceEquals(edmProperty.Documentation, null))
  2. {
  3. #>
  4. /// <summary>
  5. /// <#=edmProperty.Documentation.Summary#><#=edmProperty.Documentation.LongDescription#>
  6. /// </summary>
  7. <#}#>

After doing this I got the following in my Book.auto.cs class:

Code Snippet
  1. /// <summary>
  2. /// ISBN – International Standard Book Number
  3. /// </summary>
  4. [DataMember]
  5. public string ISBN

Then my documentation can look like this:

clip_image006

The above was created using Sandcastle and the Sandcastle Help File Builder.

Comments are closed.