开发者

With entity framework, how do I force a sql datatype for my string member

开发者 https://www.devze.com 2023-04-04 09:45 出处:网络
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)

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; }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消