Sunday, June 26, 2016

InnerException = {"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."}

This is the case if you have a date time set to 0001-01-01 because it’s out of range for Sql Server (even with Sql Server 2008 R2). In fact, Sql Server date can have date only after the year 1753.

The solution to this problem is to set a property date or to make nullable this field in the database and into your entity. This ways, you could set to null if the date is not set. Otherwise, you can use instead of of 0001-01-01 an other date has a “not set date” which is over 1753-01-01.