0

I have an entity Im updating that corresponds to a LocalDB table that includes a date column with a default applied and so Im not passing a value for the date, yet I get an error like the following

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value

I dont recall getting this kind of error (assuming I have a default on the column) when Im using SQL server.

What should I check?

BitShift
  • 123
  • 2
  • 14
  • 2
    make sure your model property has the datetime as nullable, else it will pass datetime.min which is out of range for datetime – JamieD77 Dec 11 '15 at 15:19
  • You mean on the Entity Model? – BitShift Dec 11 '15 at 15:29
  • 2
    yes.. if you set the field to allow nulls, but use a default in sql.. then your entity model should have a nullable – JamieD77 Dec 11 '15 at 15:32
  • That was it, thank you – BitShift Dec 11 '15 at 16:37
  • Possible duplicate of [Entity framework error: The conversion of a datetime2 data type to a datetime data](http://stackoverflow.com/questions/5365841/entity-framework-error-the-conversion-of-a-datetime2-data-type-to-a-datetime-da) – AHiggins Dec 14 '15 at 19:30

0 Answers0