0

I have been scaffolded existing DB from SQL Server to my project with EntityFrameworkCore and it created models with

public DateTime Birthday { get; set; }

Now I have to change DateTime to DateOnly This exception is thrown when I'm trying to read Date (SQL Server) with model which has field

public DateOnly Birthday { get; set; }

Exception: The property is of type 'DateOnly' which is not supported by the current database provider. Either change the property CLR type, or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

How can I use DateOnly struct from .NET 6.0 with SQL Server Date type?

  • 2
    Possibly related: [Support the new BCL DateOnly and TimeOnly structs for SQL Server](https://github.com/dotnet/efcore/issues/24507) – Thom A Aug 10 '22 at 09:16

0 Answers0