0

T4 enerate for me some entities like this :

public partial class Use
{

    public int UseId { get; set; }
    public int ProgramId { get; set; }
    public System.DateTime InUseDate { get; set; }
}

i whant to add documentation to this entity. i proceed like folowing:

[MetadataType(typeof(UseData))]
public partial class Use { 

}
public class UseData
{
    /// <summary>
    /// This is an ID
    /// </summary>
    [Display(
        Name = "Use ID",
        Description = "This is an ID Desc")
    ]
    public int UseId;
}

but VS autocomplete dont show me the summary of my UseIdattribute.

any ideas

Salem
  • 331
  • 1
  • 7
  • 21
  • 2
    Nice try but I would not have expected this to work. A Metadata class is used to look up attributes (metadata) on properties, the XML comments are not metadata. – H H Sep 02 '14 at 07:56
  • 1
    Use the EF Reverse POCO template! http://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838 – ErikEJ Sep 02 '14 at 08:10
  • yes, that's what i thought Henk. I tried to add the summary comment directly to my second partial class but it dosent works, VS tell me that my attribute is already defined. – Salem Sep 02 '14 at 08:14
  • I think the _property_ is already defined. – H H Sep 02 '14 at 08:28
  • @ErikEJ - how would that help, exactly? You can doctor any T4 to add "Gets or sets the UseId". – H H Sep 02 '14 at 08:31
  • @Henk That template can get the description from SQL Server meta data – ErikEJ Sep 02 '14 at 08:46
  • Right, that might be a solution. But formally the wrong place to describe the C# properties. – H H Sep 02 '14 at 09:48
  • i fond a solution here :[link](http://stackoverflow.com/questions/13931159/add-documentation-to-generated-code-in-entity-framework-model-first). auto generated from my edmx model – Salem Sep 02 '14 at 13:04

1 Answers1

2

If you're using an EDMX all you have to do is go to the entity property in the designer, open the Visual Studio properties tab and fill in the documentationScreenshot of VS EDMX Properties.

Generates code with xml summary...

    /// <summary>
    /// Database and Application Version
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Int32 MajorVersion
    {
        get
        {
            return _MajorVersion;
        }
        set
        {
            if (_MajorVersion != value)
            {
                OnMajorVersionChanging(value);
                ReportPropertyChanging("MajorVersion");
                _MajorVersion = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("MajorVersion");
                OnMajorVersionChanged();
            }
        }
    } 
Mick
  • 6,527
  • 4
  • 52
  • 67