是否有创建表时,我可以使用属性?我试图[StringLength]
但它似乎被忽略。
public class EntityRegister
{
public int Id { get; set; }
[StringLength(450)]
public string Name { get; set; }
}
另外,您也可以手动执行它Fluent API
使用HasMaxLength(450)
或者如果你想Data Annotation
,使用MaxLength
和MinLength
属性
public class EntityRegister
{
public int Id { get; set; }
[MaxLength(450)]
public string Name { get; set; }
}