Error: conversion of a datetime2 data type to a datetime data type…

Using VS2008 and Entity Framework, the exact error message is:
"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."

There are several causes for this rather generic (and not very intuitive) error message.

I had changed some fields in the SQL 2008 database from non-nullable to nullable, and then asked the tool to “update model from database”.  The error message appeared in that instance because one part of the ADO.NET Entity Data Model does not automatically get updated when this happens.  The ADO.NET Entity Data Model has three parts:
SSDL (Store Schema Definition Language)
CSDL (Conceptual Schema Definition Language)
MSL (Mapping Schema Language)

So what is the [workaround]?

The SSDL and the MSL update just fine, but I had to “hand-code” the changes in the CSDL.

And Voila!  Problem solved!

Print | posted on Sunday, September 6, 2009 5:01 PM

Feedback

# re: Error: conversion of a datetime2 data type to a datetime data type…

Left by Mubarak at 7/28/2011 7:48 AM
Gravatar Hi

I got this problem also "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."

I did not get how to “hand-code” the changes in the CSDL.

can you give more details to that?

Thanks

Your comment:





 

Copyright © intermark

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski