views:

771

answers:

1

I have a table w/ a sql date data type. When I look at the EDM markup, the storage element reflects this. The conceptual entity has a data type of DateTime (there doesn't appear to be a Date data type). When I call save changes and have a DateTime instance associated w/ the entity I want to persist, I get the following error:

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

How can I use the date data type in my schema and have EF behave? Thanks!

+6  A: 

Sounds like your SQL date column is non-nullable, but you haven't initialized the date on your entity before saving?

Craig Stuntz
Yeah I just realized this had nothing to do w/ my date column, I have another DateTime column that has a default specified within the db but I forgot to change the the StoreGeneratedPattern property in the SSDL to get this working. My bad.
James Alexander
God, I really hate EF !!!
Pop Catalin
@Pop Catalin: Hard to blame the EF here; it's behaving correctly. SQL Server just has a really weirdly limited `DateTime` range.
Craig Stuntz
@Craig Stuntz, I meant in general, this was just one of the many issues I've encountered in a very short time period ... (And BTW, EF came after SQL Server, I've expected more from EF)
Pop Catalin

related questions