开发者

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

开发者 https://www.devze.com 2023-01-14 11:55 出处:网络
Assign datetime value in code in silve开发者_Python百科rlight and save it to db by domainservice and EF:

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

精彩评论

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