The conversion from the datetime2 data type to the datetime data type generates a value out of the range, datetime2datetime
This error occurs when you use Entity Framework to operate databases.
This error is strange, in the garden saw a brother wrote that a big brother proposed the reason: http://www.cnblogs.com/plwang1990/articles/2025334.html
SqlServer2008 provides datetime2 data (more precise than datetime), while entity framework4 will default
The System. DateTime class is converted to the datetime2 type in sqlServer2008, and the attribute of the elements in your database is set to the datetime type,
If you convert datetime2 to datetime, the system will think that the data will be lost, so an error will be reported. (I think this TM is a design defect! Are you familiar with the default settings !)
After debugging, I found that this eldest brother was not totally correct. The valid range of datetime in SqlServer is January 1, January 1-9, 1753, December 31, 999. If the range is exceeded, EF converts datetime to datetime2, that is, the preceding error occurs.