If the Entity Framework updates the datetime type of the database, the conversion from the datetime2 data type to the datetime data type produces a value out of the range.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.