C
C#6mo 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
jcotton426mo ago
Are you using a recent enough .NET to use DateOnly?
Core
CoreOP6mo ago
I am using .NET 8, so I guess
Pobiega
Pobiega6mo 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
CoreOP6mo ago
Got it, thank you both. The ReadOnly type is more elegant

Did you find this page helpful?