Kir*_*eed 31 .net c# entity-framework system.componentmodel entity-framework-5
创建表时是否有可用的属性?我试过[StringLength]但似乎被忽略了.
public class EntityRegister
{
public int Id { get; set; }
[StringLength(450)]
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
Joh*_*Woo 58
或者,您可以手动执行此操作 Fluent API
使用 HasMaxLength(450)
或者如果你想Data Annotation,使用MaxLength和MinLength属性
public class EntityRegister
{
public int Id { get; set; }
[MaxLength(450)]
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)