用实体类生成表,给字段默认值怎么操作? 返回
SqlSugar
老数据
3
4273
悬赏:5 飞吻
数据库是sql server,
实体类:
[SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
public long accid { get; set; }
public System.DateTime createtime { get; set; }
我要给createtime添加默认值,默认当前日期,注解怎么写?
热忱回答(3)
-
程序 VIP0
2018/5/8未发现有生成默认值语句的功能
0 回复 -
fate stay night VIP0
2018/5/8[SugarColumn(IsOnlyIgnoreInsert=true)]publicDateTime CreateTime {get;set; }0 回复 -
程序 VIP0
2018/5/11@fate stay night:楼主说的是生成数据库表时给表字段设置默认值吧?
alter table t add constraint df DEFAULT (getdate()) for [字段]
0 回复