Search results
MaxLength is used for the Entity Framework to decide how large to make a string value field when it creates the database. From MSDN: Specifies the maximum length of array or string data allowed in a property.
25 lut 2014 · MaxLength is used for the Entity Framework to decide how large to make a string value field when it creates the database. From MSDN: Specifies the maximum length of array or string data allowed in a property.
MaxLength attribute is specifically for specifying the maximum length of a string property and is from the System.ComponentModel.DataAnnotations.Schema namespace. It allows you to specify only the maximum length constraint.
Use [MaxLength] if you need to validate the maximum length of an array or a string. Use [StringLength] if you need to validate the maximum length of a string and want to take advantage of additional features like specifying a minimum length.
[MinLength(length)] & [MaxLength(length)]: Define the minimum and maximum length for string properties. [StringLength(maxLength, MinimumLength = minLength)]: Specifies minimum and maximum lengths. [Range(min, max)]: Restricts numerical values within a specified range.
MaxLength Data Annotation Attribute is used for the Entity Framework to decide how large to make a string value field when it creates the database. According to MSDN, MaxLength Specifies the maximum length of array or string data allowed in a property.
Setting the MinimumLength property value has no effect on database configuration, but can be used to provide client-side validation in validation-aware UI frameworks, such as ASP.NET MVC. In terms of database configuration, the StringLength attribute works in the same way as the MaxLength attribute.