EntityFramework Leave SLEEPING sessions (after Firstordefault)

samir karim 25 Reputation points
2024-01-10T12:31:33.8766667+00:00

Hello ,

i use an mvc application.

and i got lot of sleeping pools in sql server after using [exec sp_who2]
User's image

and after debugging , i found that these Lines added eactly in line :

var abc = [Select].FirstOrdefault();

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,595 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,474 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dan Guzman 9,261 Reputation points
    2024-01-10T16:08:39.12+00:00

    i have max Pool size = 100 , pooling =True , min pool size = 10

    The min pool size = 10 setting means you will always have at least 10 connections once the first connection is opened. All connections will be sleeping when no query is currently executing. This is unrelated to EF or [Select].FirstOrdefault();; you will see the same behavior with any query.

    You may have more than 10 connections (up to the max pool size of 100) if over 10 queries were executed concurrently. The sleeping connections in excess of 10 will be closed after a few minutes of inactivity.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.