Create a sql2008 database from the entity model of ado.net. The date type is datetime,CodeSavechanges throws an exception when the date is modified. The exception information is:
An error occurred while updating entries. For more information, see internal exceptions
Check the internal exception information as follows:
The conversion from datetime2 data type to datetime data type generates a value out of the range
Depressed and finally found Microsoft's explanation:
System. datetime
CLRSystem.DatetimeThe type range and precision are greater than those of SQL ServerDatetimeType, which isDatacontext.CreatedatabaseMethod default type ing.To avoidDatetimeDate-related exceptions outside the range. UseDatetime2(Available from Microsoft SQL Server 2008 ).Datetime2It can be used with CLRSystem.Datetime.
From: http://msdn.microsoft.com/zh-cn/library/bb386947.aspx
Solve the problem after changing datetime to datetime2 in the database.
Create a sql2008 database from the entity model of ado.net. The date type is datetime. However, when the date is modified in the code, savechanges will throw an exception. The exception information is:
An error occurred while updating entries. For more information, see internal exceptions
Check the internal exception information as follows:
The conversion from datetime2 data type to datetime data type generates a value out of the range
Depressed and finally found Microsoft's explanation:
System. datetime
CLRSystem.DatetimeThe type range and precision are greater than those of SQL ServerDatetimeType, which isDatacontext.CreatedatabaseMethod default type ing.To avoidDatetimeDate-related exceptions outside the range. UseDatetime2(Available from Microsoft SQL Server 2008 ).Datetime2It can be used with CLRSystem.Datetime.
From: http://msdn.microsoft.com/zh-cn/library/bb386947.aspx
Solve the problem after changing datetime to datetime2 in the database.