C
C#4mo 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
jcotton424mo ago
Are you using a recent enough .NET to use DateOnly?
Core
CoreOP4mo ago
I am using .NET 8, so I guess
Pobiega
Pobiega4mo 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
CoreOP4mo ago
Got it, thank you both. The ReadOnly type is more elegant
Want results from more Discord servers?
Add your server