C
C#7mo ago
Core

EF - mapping DateTime to 'date' type in Postgres

Hello, Entity Frameworks maps DateTime to timestamp with time zone in Postgres, but how could I map it to date type?
4 Replies
jcotton42
jcotton427mo ago
Are you using a recent enough .NET to use DateOnly?
Core
CoreOP7mo ago
I am using .NET 8, so I guess
Pobiega
Pobiega7mo ago
you can override what backing type is used on a property level in the configuration (IEntityConfigurationType please), but yeah, if you want it to map to date, you should probably use DateOnly
Core
CoreOP7mo ago
Got it, thank you both. The ReadOnly type is more elegant

Did you find this page helpful?