With entity framework, how do I force a sql datatype for my string member
I have a product class, for which the ManufacturerNumber gets generated as nvarchar(max) - how would I go about forcing the code-first framework to make it nvarchar(255)
开发者_运维问答public class Product : BaseEntity
{
public string ManufacturerNumber { get; set; }
}
Decorate the property with StringLength
attribute.
public class Product : BaseEntity
{
[StringLength(255)]
public string ManufacturerNumber { get; set; }
}
精彩评论