C#C
C#4y ago
HimmDawg

❔ PostgreSQL DateTime in EF Core

So I have an app that uses EF Core with Npgsql that runs locally and I want to connect to a postgresql database which runs in a docker container. The connection and adding stuff works and all, but when I wanna save my changes, then I get this error Cannot write DateTime with Kind=Unspecified to PostgreSQL type 'timestamp with time zone', only UTC is supported.. Googling didn't really yield any valuable answers either fluffyFoxThink . So my columns are in the picture and my model is this. Any idea how to handle DateTime? in this context?
public sealed class MyModel
{
    [DataType(DataType.DateTime)]
    public DateTime? Start { get; set; }

    [DataType(DataType.DateTime)]
    public DateTime? End { get; set; }
}
image.png
Was this page helpful?