Conversions from the DATETIME2 data type to the datetime data type produce an out-of-range value

Source: Internet
Author: User

This error is encountered when using the Entity Framework to manipulate the database.
This error is rather strange, in the garden saw a brother wrote that a big brother raised the reason is: http://www.cnblogs.com/plwang1990/articles/2025334.html
The datetime2 type of data is provided in sqlServer2008 (more accurate than datetime), and the entity framework4 defaults to C #
The System.DateTime class is converted to the datetime2 type in sqlServer2008, and the attributes of the elements in your database are set to the datetime type.
Turning the datetime2 into a datetime system would think it would lose data, so it would give an error. (Feel this TM is a design flaw!) This is cooked. Default settings Ah! )
After the debugging found that the eldest brother said when not completely correct. The datetime valid range for SQL Server is January 1, 1753 through December 31, 9999, and if this range is exceeded, EF converts the datetime to datetime2, which means that the error above will occur.

Conversions from the DATETIME2 data type to the datetime data type produce an out-of-range value

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.