Entity Framework Data Annotations Set StringLength VarChar

后端 未结 2 1296
小鲜肉
小鲜肉 2020-12-01 18:05

I have this setting in my model:

[StringLength(250)]
public string Comment { get; set; }

to set the maximum length to 250 in the database w

2条回答
  •  攒了一身酷
    2020-12-01 18:11

    For some reason this older post keeps coming up in my search... so just FYI, using EF6 Core it's combined. The above answer errors out for me.

    [Column(TypeName = "VARCHAR(250)")]
    public string Comment {get;set;}
    

提交回复
热议问题