DataAnnotation for Required property

Okay. Though I have not complete understood this thing. A workaround is found.

In Global.asax:

GlobalConfiguration.Configuration.Services.RemoveAll(
    typeof(System.Web.Http.Validation.ModelValidatorProvider),
    v => v is InvalidModelValidatorProvider);

I found it in the Issue Tracker in aspnetwebstack. Here is the link to the page:

Overly aggressive validation for applying [DataMember(IsRequired=true)] to required properties with value types

If anyone can tell us why it is like this, please post your insight as answers. Thank you.

Leave a Comment