My Code First models have System.DateTime
properties. When the database seeding code is invoked, it throws this exception:
SqlException (0x80131904): The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
I am creating a new DateTime
object with the constructor. Code First is creating the database schema. How do I overcome this apparent bug in Code First? I am not particular about my datatype. I merely need to store a date, and optionally a time of day, but not crucial.
I have searched and read a lot of posts, but none with this error specify they come from CodeFirst-generated data scheme. The closest answer I found involved making a change to the ProviderManifestToken
in the edmx
file, but my project does not have an edmx
file. I did not use the designer, I am using Code First.