I have a view model like this.
public class ModelTest
{
public ModelTest()
{
Name = "Jim";
}
[Required]
public string Name { get; set; }
[ScaffoldColumn(false)]
public string IgnoreMe { get; set; }
}
and an Action
public IActionResult TestModel(ModelTest model)
{
var valid = ModelState.IsValid;
return Json(ModelState);
}
Previously in ASP.NET MVC 5 this would be valid as the DataAnnotationsModelValidatorProvider ignored ScaffoldColumns when performing validation, so the ModelState.IsValid would be true. But in ASP.NET MVC Core 8 it is false and the ModelState is
{
"IgnoreMe": {
"RawValue": null,
"AttemptedValue": null,
"Errors": [
{
"Exception": null,
"ErrorMessage": "The IgnoreMe field is required."
}
],
"ValidationState": 1,
"IsContainerNode": false,
"Children": null
}
}
Is there any way to change this behaviour and ignore ScaffoldColumn’s?