I have model class which consist of 3 required field. I am submitting MVC form with only 2 required fields and keeping one field blank (PhoneNumber).
public class User
{
[Required]
public String UserName { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string PhoneNumber { get; set;}
}
On Action result, I got ModelState Invalid that is true. I then remove that invalid property from ModelState using ModelState.Remove("PhoneNumber");
I then again check ModelState becomes true after that.
but while saving model, it is throwing entity validation error because of blank field (PhoneNumber) although I removed invalid property from ModelState. How to skip entity validation error in such scenario and let save the model in database.