__Repro Steps__
* Create webapi2 project
* Create a simple class with validation attribute on a field
public class Person
{
public int Id { get; set; }
[StringLength(4)]
public string MyName;
public string Name
{
get { return MyName; }
set { MyName = value; }
}
}
* Create a Webapi controller with EF for "Person".
* Now try to insert a Peron entity into database.
Expected: This fails.
Observed: It works fine.
On Webapi 1, I see following error when I follow steps above
ExceptionMessage=Field 'MyName' on type 'WebApplication2.Models.Person' is attributed with one or more validation attributes. Validation attributes on fields are not supported. Consider using a public property for validation instead.
* Create webapi2 project
* Create a simple class with validation attribute on a field
public class Person
{
public int Id { get; set; }
[StringLength(4)]
public string MyName;
public string Name
{
get { return MyName; }
set { MyName = value; }
}
}
* Create a Webapi controller with EF for "Person".
* Now try to insert a Peron entity into database.
Expected: This fails.
Observed: It works fine.
On Webapi 1, I see following error when I follow steps above
ExceptionMessage=Field 'MyName' on type 'WebApplication2.Models.Person' is attributed with one or more validation attributes. Validation attributes on fields are not supported. Consider using a public property for validation instead.