dotnet / dotnet/efcore

SqlError number 4060 (user login failed as default database doesn't exist) shouldn't retry

Open
#33,191 20 comments 0 reactions 1 assignee Claimed by @AndriySvyryd View on GitHub
area-aspire area-execution-strategies needs-design
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

`SqlServerRetryingExecutionStrategy` today treats a `SqlError.Number == 4060` as a transient exception that can be retried. This error occurs when the login credentials are valid but the requested default database can't be accessed (e.g. when it hasn't been created by migrations yet, see [details here](https://learn.microsoft.com/sql/relational-databases/errors-events/database-engine-events-and-errors-4000-to-4999?view=sql-server-ver16)). This leads to a poor developer experience in the case of an ASP.NET Core project configured with the EF Core migrations endpoint and developer exception page filter that displays an "Apply migrations" button, as the page won't be displayed until the retry loop has been completely exhausted (minutes).

The Npgsql retry strategy treats the equivalent PostgreSQL error as fatal and doesn't retry.

It's possible that other 406x error numbers should be consider fatal too.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.