0
votes

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?

1
figure it out. becuase more than one item for DateTime. And some of them not set value(null).KentZhou

1 Answers

0
votes

In your model put a questionmark behind the datatype.

public DateTime? myDate {get; set;}

This will allow NULL to be written in the database.