Please try adding this piece of code NpgsqlConnection.GlobalTypeMapper.EnableDynamicJson(); as mentioned in this page https://www.npgsql.org/doc/types/json.html?tabs=global
NpgsqlConnection.GlobalTypeMapper.EnableDynamicJson();