Saturday, November 18, 2017

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

Solution:
"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value" with Entity Framework when calling SaveChanges.

Go into your EDMX file, select the field that is causing the error and set StoreGeneratedPattern to Computed.








Add the DatabaseGenerated attribute if you are using EF Code First:

[DatabaseGenerated(DatabaseGeneratedOption.Computed)]

public Nullable<System.DateTime> Created { get; set; }

No comments:

Post a Comment

Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.Please don't spam,spam comments will be deleted upon reviews.