开发者

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value

Assign datetime value in code in silve开发者_Python百科rlight and save it to db by domainservice and EF: DateCreated = DateTime.Now

in database, the mapped column datetype is datetime, not datetime2.

then got following error: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.

How to fix it?


In your model put a questionmark behind the datatype.

public DateTime? myDate {get; set;}

This will allow NULL to be written in the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜