Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
SqlClient's connection resiliency adds 10 seconds to database existence checks. Consider exposing a way to override it at runtime #14644
This is to follow up on a specific issue a customer created today on EF Core at aspnet/EntityFrameworkCore#7283, but the problem has been brought to our attention before.
Both EF6 and EF Core provide APIs that allow applications to create and initialize databases, check for their existence and modify their schemas. These operations can happen at design time (e.g. when using the migrations feature) or at runtime. Attempting to connect to a database that doesn't exist is part of the normal flow of these operations.
In .NET Framework 4.5.1 SqlClient introduced a connection resiliency feature that performs automatic retries if failures occur during
With only the default behavior this feature introduces a lag of 10 second for any calling code that attempts to connect to a database that doesn't exist. It also prevents any calling code from implementing its own (potentially more efficient) retry logic correctly. This severely affects customer experience and can potentially affect runtime performance.
Two main approaches have been proposed to mitigate this issue on EF code, but they have severe disadvantages:
At this point we believe that if
Also note that this issue applies to both .NET Core and .NET Framework.
Note on how EF Core implements its own retry logic to check for database existence:
In general, any code that is calling