Fork me on GitHub

[ABP] PostgreSQL在.NET 6.0使用DateTime类型抛出异常:timestamp with time zone

InvalidCastException:'timestamp with time zone'. See the Npgsql.EnableLegacyTimestampBehavior AppContext switch to enable legacy behavior. 搜关键词 `EnableLegacyTimestampBehavior`,找到官网的解释:https://www.npgsql.org/doc/types/datetime.html#timestamps-and-timezones 在 `Main` 入口加上 ```C# AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); ``` 重新执行 `dotnet run` 命令,问题解决。
posted @ 2022-03-28 00:12  VAllen  阅读(2986)  评论(0编辑  收藏  举报