core ef 对象对应sql数据库字段长度

sqlserver中nvarchar(50),对应EF中:

[MaxLength(50, ErrorMessage = "最大长度为{1}")]
public string Name { get; set; }

sqlserver中char(10),对应EF中:

[MaxLength(10)]
[Column(TypeName = "CHAR")]
public string Name { get; set; }

sqlserver中smallint,对应EF中:

public short ID { set; get; }

sqlserver中tinyint,对应EF中:

public byte IsDelete { get; set; }

sqlserver中text,对应EF中:

[Column(TypeName = "text")]
public string Content { set; get; }

sqlserver中Date(sqlserver2008版本以上才有),对应EF中

[Column(TypeName = "smalldatetime")]//年月日时分秒
public DateTime Birthday{ get; set; }

sqlserver中decimal,对应EF中

[Column(TypeName = "decimal(18, 2)")]
public decimal Money { get; set; }

 

posted @ 2022-07-23 21:15  流氓大菠萝  阅读(214)  评论(0编辑  收藏  举报