Have you tried setting the MaxPoolSize=XXX in your connection string? It defaults to 100 but you can change it.
Seeing connection time out error due to "max pool size was reached" when using Microsoft.Data.SqlClient package
Recently we have upgraded our nuget packages from "System.Data.SqlClient" to "Microsoft.Data.SqlClient" then started seeing below error more often in local when connecting to local DB. We haven't seen this error previously and thus I am wondering if its related to nuget package upgrade. The project is on TargetFramework "net472".
We are appropriately closing all the connections with the help of using statement and have never seen this before when we were on "System.Data.SqlClient" package.
Error Msg:
System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.. Aborting test execution.
Developer technologies | ASP.NET | ASP.NET Core
SQL Server | Other
Developer technologies | C#
2 answers
Sort by: Most helpful
-
Greg Low 1,980 Reputation points Microsoft Regional Director
2024-02-09T04:47:10.42+00:00 -
Olaf Helper 47,441 Reputation points
2024-02-09T07:16:50.8666667+00:00 This may have occurred because all pooled connections were in use and max pool size was reached.
Often cause is when you don't cleanly dispose manged object like SqlConnection, so that the connection gets back to the pool for beeing resued.