我想,因为,因为我目前的项目配置的详细信息添加到马特Mhetton的回答(CA和风格警察)一切都必须记录..
一方面,你必须在设计中添加文档属性要记录(类,简单性,复杂性和导航性能)
在你要打开WhateverModel另一方面应有尽有。 TT你havecreated和编辑,使其包含的文件,我将解释一步一步来:
1.-对于类文档,寻找:
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
<#=codeStringGenerator.EntityClassOpening(entity)#>
(在我的情况下,第26行),把你的意见只是那些两条线这样间:
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
<# if (entity != null && entity.Documentation != null) {#>
/// <summary>
/// <#= entity.Documentation.Summary #>
/// </summary>
<# } #>
<#=codeStringGenerator.EntityClassOpening(entity)#>
2:对于构造文档找public <#=code.Escape(entity)#>()
thaqt就是生成的构造函数,因此把你的文件只是在此之前,像这样一行:
<# if (entity != null && entity.Documentation != null) {#>
/// <summary>
/// <#= entity.Documentation.Summary #>
/// </summary>
<# } #>
public <#=code.Escape(entity)#>()
{
3.-为了证明每个属性找foreach (var edmProperty in simpleProperties)
,这看起来是一个将生成的属性代码,因此,它应该是这样的:
foreach (var edmProperty in simpleProperties)
{
#>
<# if (edmProperty != null && edmProperty.Documentation != null) {#>
/// <summary>
/// <#= edmProperty.Documentation.Summary #>
/// </summary>
<# } #>
<#=codeStringGenerator.Property(edmProperty)#>
<#
}
(注:这是简单的性质,但要BE3复杂性以同样的方式...)
4.-对于导航属性一模一样,寻找foreach (var navigationProperty in navigationProperties)
并添加你的文档是这样的:
foreach (var navigationProperty in navigationProperties)
{
#>
<# if (navigationProperty != null && navigationProperty.Documentation != null) {#>
/// <summary>
/// <#= navigationProperty.Documentation.Summary #>
/// </summary>
<# } #>
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
<#
}
4.-最后但并非最不重要的,如果你还需要在你的上下文类文档你可以使用这个(寻找<# 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>
<# } #>
我希望它能帮助像Matt Whetton的回答帮助我(谢谢Matt)。
谢谢,非常有帮助!有关处理文档中换行符的最佳方法的任何建议?使用上面的方法,评论(///)不会在Summary \ LongDescription – mutex
中为每个换行重复实际执行如下操作:edmProperty.Documentation.Summary.Replace(“\ n”,“\ r \ n \ t // /“)可以做到这一点,还有额外的好处,它可以防止视觉工作室关于行尾的恼人警告不一致。 – mutex