存入的数据为 UTC 时间库,库中对应字段还是本地时间。
.net core 3.x
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
// for npgsql time zone problem
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
}
.net6
var builder = WebApplication.CreateBuilder(args);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);