npgsql连接池重复认证

npgsql connection pool repeated authentication

我正在使用 Npgsql.EntityFrameworkCore.PostgreSQL 2.1.2、EfCore 2.2、asp.net 3.1。

连接池已启用(不在连接字符串中传递)。 启用日志记录后,我得到这样的日志:

2021-05-19 10:23:21.542 +02:00 Opening connection...
2021-05-19 10:23:21.545 +02:00 Attempting to connect to xxx.xxx.xxx.xxx:5432
2021-05-19 10:23:21.595 +02:00 Socket connected to xxx.xxx.xxx.xxx:5432
2021-05-19 10:23:21.597 +02:00 Authenticating...
2021-05-19 10:23:21.914 +02:00 A PostgreSQL type with the name hstore was not found in the database
2021-05-19 10:23:21.916 +02:00 A PostgreSQL type with the name citext was not found in the database
2021-05-19 10:23:21.918 +02:00 A PostgreSQL type with the name unknown was not found in the database
2021-05-19 10:23:21.921 +02:00 Opened connection to xxx.xxx.xxx.xxx:5432

对于执行的每个查询都会重复此行为。如您所见,似乎每次它都执行新的身份验证(需要 300ms)。 这样看来连接池似乎不起作用,因为我希望每次都重用连接。我还尝试添加 dbcontextpooling,结果保持不变。 有什么提示吗?

糟糕,我发现每次关闭连接时我们都会显式清空池:(