In my code first model I have the following.
public class Agreement
{
[Key]
[ForeignKey("AppRegistration")]
public int AppRegistrationId { get; set; }
[Required]
[Display(Name = "I agree to Participation Agreement")]
[NotMapped]
public bool IsAgreementChecked { get; set; }
public DateTime DateAgreed { get; set; }
public AppRegistration AppRegistration { get; set; }
}
I have marked IsAgreementChecked
as NotMapped
because I only want to store the DateTime
when the user clicked the Agree checkbox.
When I generate the Controller
based on this model and try to use the Create page. All the fields validate properly but the checkbox is ignored. In other words, the checkbox does not trigger any sort of validation. Any ideas? Thanks.