我有Entity Framework 6模板文件。我想在[XmlIgnore]
上加public virtual ICollection
,因为它无法序列化。
这个模板文件生成设计器类,我不希望编辑设计器类,以便在生成后编辑设计器类来包含[XmlIgonre]
。我想编辑模板,因此public virtual ICollection
所有行都将具有[XmlIgnore]
属性。
答案 0 :(得分:0)
你必须找到并编辑它(在你的模型tt文件中):
ip
对此:
<#
foreach (var navigationProperty in navigationProperties)
{
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
{
#>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
<#
}
#>
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
<#
}
}
#>