MetadataType doesn't recognize IgnoreDataMemberAttribute

686 Views Asked by At

I have an entity which is auto generated by Entity Framework from database

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).

[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?

1

There are 1 best solutions below

3
On

Use [NotMapped] attribute. See the NotMappedAttribute Class on MSDN.