entity hassle
entity hassle

Reputation: 1

How to track open database connections with Entity Framework Core 8?

I have an ASP.NET Core 8 MVC application. In production the application throws an error

Npgsql.PostgresException (0x80004005): 08P01: no more connections allowed (max_client_conn)

I am using NPGSQL and Entity Framework Core.

I am trying to diagnose if there is a leaky connection not being closed. Everywhere I have found is using dependency injection to handle getting the databaseContext.

Is there a way to get a list of database connections from Entity Framework Core so I can track when one is being opened and when that same connection is being closed?

I have tried using logTo() which can log when a DB connection is opened or closed but that does not say when which connection is closed or what the context is for the connection being opened.

I have also tried using DiagnosticListeners to see when connections are opened but that does not give any more information that the logTo() method.

Upvotes: 0

Views: 47

Answers (0)

Related Questions