I would like to close all idle connections in the SqlClient connection pool. Is there a documented method for doing this?
The issue is that as part of the normal processing of this application (A testing harness) I need to drop the database and recreate it at the start of each test scenerio. Obviously I can’t drop the database with active connections (active from Sql Server’s point of view not the client)
In general, no. Specific database providers may provide a way of doing this. SqlClient provides a similar feature via SqlConnection.ClearPool and SqlConnection.ClearAllPools — but these do not close any open connections, they just clear out connections that have been returned to the pool.