向实体框架生成的实体添加文档

时间:2014-09-02 07:51:06

标签: c# entity-framework visual-studio-2013 code-generation

T4为我带来了一些像这样的实体:

public partial class Use
{

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

我想向这个实体添加文档。我继续跟进:

[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;
}

但VS自动完成不会向我显示我的UseIdattribute的摘要。

任何想法

1 个答案:

答案 0 :(得分:2)

如果您正在使用EDMX,您只需转到设计器中的entity属性,打开Visual Studio属性选项卡并填写文档Screenshot of VS EDMX Properties

使用xml摘要生成代码...

    /// <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();
            }
        }
    }