Skip to content

Commit

Permalink
Use the new OpenAsync overload
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Jan 30, 2025
1 parent aed151a commit b4477ba
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public SqlServerConnection(RelationalConnectionDependencies dependencies)
/// </summary>
protected override void OpenDbConnection(bool errorsExpected)
{
// Note: Not needed for the Async overload: see https://github.com/dotnet/SqlClient/issues/615
if (errorsExpected
&& DbConnection is SqlConnection sqlConnection)
{
Expand All @@ -50,6 +49,25 @@ protected override void OpenDbConnection(bool errorsExpected)
}
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override Task OpenDbConnectionAsync(bool errorsExpected, CancellationToken cancellationToken)
{
if (errorsExpected
&& DbConnection is SqlConnection sqlConnection)
{
return sqlConnection.OpenAsync(SqlConnectionOverrides.OpenWithoutRetry, cancellationToken);
}
else
{
return DbConnection.OpenAsync(cancellationToken);
}
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down

0 comments on commit b4477ba

Please sign in to comment.