I have this database column:
[MaxLength(10)]
[Required]
public List<NpgsqlRange<System.DateTime>> Dates { get; set; }
How do I make this allow only Kind.Unspecified?
I get this error when I insert:
System.InvalidCastException : Cannot write DateTime with Kind=Unspecified to PostgreSQL type 'timestamp with time zone', only UTC is supported. Note that it's not possible to mix DateTimes with different Kinds in an array/range. See the Npgsql.EnableLegacyTimestampBehavior AppContext switch to enable legacy behavior.
Every single solution I have seen is to use Npgsql.EnableLegacyTimestampBehavior. However, that is to allow unspecified type in a UTC column, and I don't want to allow unspecified type in a UTC column. I want the column to be strongly typed as unspecified.
Also, when I use EnableLegacyTimestampBehavior, it saves it to postgresql with the "+12" in it, which IS UTC (which I don't want).
Dates = table.Column<List<NpgsqlRange<System.DateTime>>>(type: "tstzmultirange", maxLength: 10, nullable: true)