Efcore: SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Created on 2 May 2020  ·  3Comments  ·  Source: dotnet/efcore


I am using Microsoft.EntityFrameworkCore.SqlServer, Version=5.0.0-preview.3.20181.2

Exception log: https://gist.github.com/donhuvy/71d1773effecd39c561c2e8ccb4396ec

exception

razor

Blazor razor file https://gist.github.com/donhuvy/ecb28b20764cf57bffb914baa01c8fbe#file-salevoucher-razor-L333

database: https://gist.github.com/donhuvy/98268691b37a02cf74d273cb74dc37dc#file-applicationdbcontext-cs-L6148

My model: https://gist.github.com/donhuvy/61810e01a8c1c400314a95687cb0e5e7

My form: https://gist.github.com/donhuvy/339cd6d48c147aa7e8180f373fb0c7ca

dot net ef https://gist.github.com/donhuvy/e3e0a22949fdbba9de7a65ba10089033

Visual Studio: https://gist.github.com/donhuvy/f8e5a3ffa5888f04569b6f26a1f8650b

select @@VERSION;
Microsoft SQL Server 2019 (RTM-GDR) (KB4517790) - 15.0.2070.41 (X64)   Oct 28 2019 19:56:59   Copyright (C) 2019 Microsoft Corporation  Enterprise Evaluation Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 18363: ) 

Steps to reproduce

My Visual Studio project file: https://gist.github.com/donhuvy/4ceb946c35e132c40271929ac480aebe#file-acc133balzor-proj-L25

Further technical details

EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 5.0 preview
Operating system: Windows 10 x64 pro
IDE: Microsoft Visual Studio Community 2019 Preview
Version 16.6.0 Preview 5.0

closed-question customer-reported

Most helpful comment

@donhuvy
You are not passing data to PostedDate, which is a non-null field, SQL Server expects a minimum value of 1/1/1753, and .NET the minimum value is 1/1/0001, so it passes the value in PostedDate that solved your problem!

All 3 comments

If the SQL Server data type is "datetime", the lowest possible value is what the error message clearly states.

@donhuvy
You are not passing data to PostedDate, which is a non-null field, SQL Server expects a minimum value of 1/1/1753, and .NET the minimum value is 1/1/0001, so it passes the value in PostedDate that solved your problem!

@donhuvy
You are not passing data to PostedDate, which is a non-null field, SQL Server expects a minimum value of 1/1/1753, and .NET the minimum value is 1/1/0001, so it passes the value in PostedDate that solved your problem!

Thanks @ralmsdeveloper , It works. I am sorry, it is not a bug.

Was this page helpful?
0 / 5 - 0 ratings