0

Assign datetime value in code in silverlight and save it to db by domainservice and EF: DateCreated = DateTime.Now

in database, the mapped column datetype is datetime, not datetime2.

then got following error: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.

How to fix it?

KentZhou
  • 24,805
  • 41
  • 134
  • 200
  • Possible duplicate of: [The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.](http://stackoverflow.com/questions/1678474/the-conversion-of-a-datetime2-data-type-to-a-datetime-data-type-resulted-in-an-ou) – Joe Stefanelli Sep 02 '10 at 19:24
  • figure it out. becuase more than one item for DateTime. And some of them not set value(null). – KentZhou Sep 02 '10 at 19:59

1 Answers1

0

In your model put a questionmark behind the datatype.

public DateTime? myDate {get; set;}

This will allow NULL to be written in the database.

Eric
  • 339
  • 3
  • 14