DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

How to Configure ADO.NET Connection Pooling in ASP.NET Core

Microsoft.Data.SqlClient pools connections by default. Configure its options carefully, dispose connections promptly, and diagnose fragmentation and long-held work before increasing pool limits.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For Microsoft.Data.SqlClient in ASP.NET Core, connection pooling is enabled by default: configure the provider through the connection string, open a logical connection only when database work is ready, and dispose it as soon as that work finishes. The pool—not a process-wide connection you keep open—reuses physical connections. The defaults are starting points, not universal capacity recommendations.

How ADO.NET connection pooling works

When your application opens a SqlConnection, Microsoft.Data.SqlClient can supply a physical database connection from a matching pool. Disposing or closing the logical connection returns it for reuse when its configuration and transaction context permit. Your code should still create and dispose a connection for each unit of work; pooling is not a reason to hold one global connection open. Microsoft’s guidance is: “Open late, dispose early, and let the pool manage physical connections.” (Microsoft Learn: SQL Server connection pooling with Microsoft.Data.SqlClient.)

As an Amazon Associate I earn from qualifying purchases.

Which connection-string settings control the pool?

Microsoft documents these defaults for Microsoft.Data.SqlClient. They are provider defaults, not a tuning prescription for every application.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Documented default What it controls
Pooling true Enables pooling. Set it to false only when you deliberately need to disable reuse.
Min Pool Size 0 Minimum physical connections retained by the pool. A positive value can keep database sessions open.
Max Pool Size 100 Maximum physical connections in one pool—not a process-wide or server-wide total.
Connect Timeout 15 seconds Time allowed to establish a connection or wait for an available pooled connection when the pool is full.
Load Balance Timeout 0 Age-based connection discarding; zero disables it. Connection Lifetime is an alias.

These defaults are documented in Microsoft’s Microsoft.Data.SqlClient connection options. Increasing a limit or setting a nonzero minimum changes resource use; it does not by itself fix slow queries, leaked connections, or database capacity constraints.

Keep connection configuration consistent

A connection is reused only by a pool matching its configuration. Exact connection-string text matters: changing keyword order can create a separate pool even when the effective settings are equivalent. Authentication identity, credentials or token handling, application name, and other settings can also affect pool selection. Transaction-enlisted connections may be held in transaction-specific subdivisions.

Use a canonical connection configuration across requests. Avoid placing per-request values in connection-string fields such as Application Name; variation can fragment reuse and multiply the connections your application may open. Microsoft documents the matching behavior in its connection-pooling overview.

Set provider options without keeping connections open

Pooling controls belong to the SqlClient connection configuration. A SqlConnectionStringBuilder helps set and validate options instead of assembling a string by concatenating values. Do not concatenate user-supplied values into a connection string; Microsoft describes the SqlConnection.ConnectionString property and builder approach.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, at the provider level, a builder can set pool options before creating a connection:

var builder = new SqlConnectionStringBuilder(existingConnectionString)
{
    Pooling = true,
    MinPoolSize = 0,
    MaxPoolSize = 100,
    ConnectTimeout = 15
};

using var connection = new SqlConnection(builder.ConnectionString);
await connection.OpenAsync();
// Run the database work, then dispose the connection promptly.

This illustrates SqlClient options, not a prescribed ASP.NET Core configuration or secret-storage recipe. The Microsoft configuration reference available here includes older ASP.NET configuration examples, so its web.config pattern should not be treated as an ASP.NET Core setup guide: Connection strings and configuration files.

Prevent pool exhaustion before raising the limit

When a pool reaches its maximum, later connection opens wait for an available connection up to Connect Timeout. If none becomes available in time, connection acquisition fails with a timeout. The maximum applies per pool; the possible total also depends on how many distinct pools and application instances are running. Raising Max Pool Size without correcting long-held connections can shift the overload to SQL Server.

  1. Check disposal on every path. Inspect code that opens connections, data readers, and transactions. Ensure they are disposed even when an exception occurs, and that readers do not outlive the work that needs them.
  2. Look for multiple pools. Compare connection strings and authentication details used by different call paths. Differences such as keyword ordering or request-specific values can prevent reuse.
  3. Find work that holds connections too long. Review long-running queries and transactions, and reduce avoidable time between opening a connection and finishing database work.
  4. Estimate aggregate demand. Account for each pool and each service replica, then compare the possible connection total with database capacity.
  5. Change limits only with evidence. After the earlier checks, consider a measured adjustment if workload concurrency and database capacity support it.

For SqlClient-specific failure symptoms and investigation guidance, see Microsoft’s SqlClient Troubleshooting Guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep ambient transactions bounded

With Enlist=true, the default, connections opened within an ambient System.Transactions transaction automatically enlist. If a connection closes while that transaction is still active, it may remain in a transaction-specific subdivision until the transaction completes, making it unavailable to ordinary requests in the meantime. Keep ambient transactions short and complete them explicitly.

When to clear a pool

SqlClient can clear a pool automatically after certain recognized fatal errors, such as failover. ClearPool targets the pool associated with a connection configuration; ClearAllPools clears all SqlClient pools in the process or application domain. Clearing idle and checked-out connections leads to new physical logins as connections are needed. Use these APIs for a known configuration or credential boundary—not as periodic cleanup or a substitute for disposing connections. See Microsoft’s ADO.NET Provider for SQL Server pooling reference.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.