Entity Framework MinLength Data Annotation
The MinLength attribute allows you to specify additional property validations. It is applied to a property to specify a minimum number of characters or bytes for the column that the property should map to.
The following example specifies that the Title column in the Books table must have a minimum length of 5 characters.
public class Book { public int BookId { get; set; } [MinLength(5)] public string Title { get; set; } }
If you set a value of the Title property less than the specified length in the MinLength attribute, EF will throw an EntityValidationError.
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
ZZZ Projects