I have a partial class with validation attributes -
[MetadataTypeAttribute(typeof(tblPersonMetadata))]
public partial class tblPerson
{
}
public class tblPersonMetadata
{
[MaxLength(80)]
public string PER_MiddleName { get; set; }
[Required(ErrorMessage = "Enter your Gender")]
public string PER_Gender { get; set; }
}
The tblPerson is an entity in Entity Framework used in multiple locations. In some locations, I want to leave PER_MiddleName and PER_Gender empty.
How can I selectively disable the validation when tblPerson is used in some objects?