I know there are a ton of posts about this issue but none of them seem to solve my problem.
Here's the scenario:
I have a CreateDate DateTime column in my MS SQL Server database User table that is non-nullable and is automatically set using GetDate() method in "Default Value or Binding" setting.
I am able to create a User just fine with the standard EF Insert but when I try to update the user, I get this error:
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
What is the trick to not having the EF worry about the CreateDate column for updates? I have the StoreGenerationPattern = Identity but that isn't helping.
Here are the EF properties for my Entity Property: http://screencast.com/t/8ndQRn9N
And here is my Update method: http://screencast.com/t/UXIzhkhR
Have you tried setting the StoreGeneratedPattern attribute to 'Computed'. Failing that, as a last resort, try changing the column's datatype to datetime2
.
[The problem arises because the .NET DateTime.MinValue
equals 0001-1-1 but Sql Server DateTime
covers 1753-1-1 through 9999-12-31]