[英]MetadataType doesn't recognize IgnoreDataMemberAttribute
I have an entity which is auto generated by Entity Framework
from database 我有一个由Entity Framework
从数据库自动生成的Entity Framework
public partial class Demand : Entity
{
public string Description { get; set; }
public virtual ICollection<DemandUserComment> DemandUserComments { get; set; }
}
then added A MetadataType
to add DataContract
and DataMemeber
attributes to that Entity (independent of Db changes). 然后添加一个MetadataType
以将DataContract
和DataMemeber
属性添加到该实体(与Db更改无关)。
[DataContract(IsReference=true)]
internal class DemandMetaData
{
[IgnoreDataMember]
public virtual ICollection<DemandUserComment> DemandUserComments { get; set; }
}
[MetadataType(typeof (DemandMetaData))]
public partial class Demand
{
}
but the [IgnoreDataMember]
doesn't apply to Demand
how can I handle it? 但是[IgnoreDataMember]
不适用于Demand
,我该如何处理?
Use [NotMapped]
attribute. 使用[NotMapped]
属性。 See the NotMappedAttribute Class on MSDN. 请参阅MSDN上的NotMappedAttribute类 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.