efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

Backward compatibility of SQL translation for DateTime.Date

Open tom-puckett opened this issue 1 year ago • 0 comments

We are in the process of moving an application to .NET 8 and all related packages, including npgsql EF Core. Our database is still on PostgreSQL 11, which remains supported in Azure until (I think) next year even though it is no longer maintained.

A query expression using DateTime.Date has previously worked until this current change and we have traced the issue to the date_trunc PostgreSQL function, which appears to have changed from 2 parameters to 3 starting with PostgreSQL 12. We have tried forcing the context to generate SQL for PG 11 using code like optionsBuilder.UseNpgsql(connectionString, o => o.SetPostgresVersion(11, 0)); but the generated SQL continues to have 3 parameters.

Does the translation with the 3rd parameter depend on the Kind of the DateTime value?

We do plan to migrate to PG 16 or newer by next year but it's not possible right now. Is there something else we can try or any other recommendation? Is it a defect?

tom-puckett avatar Jul 01 '24 15:07 tom-puckett