开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜