public class tblStudentAddress :UpdateDates
{
[Key]
public int StudentAddressId { get; set; }
[ForeignKey("StudentId")]
public virtual tblStudent tblStudent { get; set; }
public int StudentId { get; set; }
[Required(ErrorMessage = "PinCode is required")]
[RegularExpression(@"^[0-9]{6}", ErrorMessage = "Invalid PinCode")]
public int StudentPincode { get; set; }
[NotMapped]
[RegularExpression(@"^\d{6}(-\d{6})?$", ErrorMessage = "Invalid Zip")]
public int StudentTempPinCode { get; set; }
StudentTempPincode的值保存为studentAddressTable的下一行,具有相同的studentId(可以添加多个pincodes)。我试过这个显示一些错误,如
StudentTempPinCode中的实体验证错误