Entity framework error: The conversion of a datetime2 data type to a datetime data

前端 未结 2 1311
不思量自难忘°
不思量自难忘° 2021-01-23 05:14

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 Date

相关标签:
2条回答
  • 2021-01-23 05:59

    I know this is an old question but maybe this may help someone:

    The problem may be a bug that causes StoreGeneratedPattern in the Conceptual section (CSDL) of the .edmx file to be out of sync with the StoreGeneratedPattern in the Storage section (SSDL). The GetDate() default is never called because - unless you assign the date from your client-side code - the default value of DateTime.MinValue is used.

    The good news is, it's fixed. Look for KB2561001: http://archive.msdn.microsoft.com/KB2561001. I don't know if this is fixed in the subsequent EF 4.3 release or you still have to apply the hotfix.

    0 讨论(0)
  • 2021-01-23 06:15

    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]

    0 讨论(0)
提交回复
热议问题