포스트그레스 사용 시 다음과 같은 에러가 나는 경우가 있습니다.
System.InvalidCastException: ''timestamp with time zone' literal cannot be generated for Local DateTime: a UTC DateTime is required'

포스트그레스 프로바인더가 6.x 버전부터 시간대가 포함된 타임스템프(timestamp with timezone)로 매핑해야 한다고 합니다.
간편하게 해결하는 방법은 'DbContext'를 생성할 때 레거시 모드를 설정해 주는 것입니다.
	public ModelsDbContext_Postgresql(DbContextOptions<ModelsDbContext> options)
		: base(options)
	{
        //https://duongnt.com/datetime-net6-postgresql/
        //https://stackoverflow.com/questions/69961449/net6-and-datetime-problem-cannot-write-datetime-with-kind-utc-to-postgresql-ty
        AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
    }
레거시 모드를 쓰기 싫다면 모든 'DateTime' 컬럼을 수작업으로 변환해야 합니다.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<BoardPost>()
        .Property(p => p.WriteTime)
        .HasConversion
        (
            src => src.Kind == DateTimeKind.Utc ? src : DateTime.SpecifyKind(src, DateTimeKind.Utc),
            dst => dst.Kind == DateTimeKind.Utc ? dst : DateTime.SpecifyKind(dst, DateTimeKind.Utc)
        );
}
참고 : Duong's Blog - Datetime error with .NET 6 and PostgreSQL
stackoverflow - .NET6 and DateTime problem. Cannot write DateTime with Kind=UTC to PostgreSQL type 'timestamp without time zone'
형식이 바뀌면 골치 아파지는 건 어쩔 수 없습니다 ㅎㅎㅎㅎ
그래도 비교적 쉬운 해결 방법이 있다는 것에 감사해야죠.