Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 3 additions & 33 deletions docs/connect/ado-net/appcontext-switches.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: AppContext switches in SqlClient
description: Learn about the AppContext switches available in SqlClient and how to use them to modify some default behaviors.
author: David-Engel
ms.author: davidengel
ms.reviewer: v-davidengel
ms.date: 05/10/2023
author: cheenamalhotra
ms.author: cmalhotra
ms.date: 08/19/2025
ms.service: sql
ms.subservice: connectivity
ms.topic: conceptual
Expand All @@ -18,18 +17,6 @@ ms.custom: sfi-ropc-nochange

The AppContext class allows SqlClient to provide new functionality while continuing to support callers who depend on the previous behavior. Users can opt out of a change in behavior by setting specific AppContext switches.

## Force use of operating system encryption protocols

[!INCLUDE [appliesto-netfx-netcore-netst-md](../../includes/appliesto-netfx-netcore-netst-md.md)]

Starting with Microsoft.Data.SqlClient 4.0, TLS 1.3 isn't supported by the driver and was removed from the supported protocols list by default. Users can switch back to forcing use of the operating system's client protocols, by setting the AppContext switch **"Switch.Microsoft.Data.SqlClient.UseSystemDefaultSecureProtocols"** to true:

```csharp
AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseSystemDefaultSecureProtocols", true);
```

Starting with version 5.0, TLS 1.3 is supported in TDS 8.0 connections without having to use the above switch. TDS 8.0 is enabled when `Encrypt` is set to `Strict`.

## Enabling decimal truncation behavior

[!INCLUDE [appliesto-netfx-netcore-netst-md](../../includes/appliesto-netfx-netcore-netst-md.md)]
Expand Down Expand Up @@ -102,23 +89,6 @@ Starting in version 3.0, ReadAsync runs asynchronously. Previous versions run Re
AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.MakeReadAsyncBlocking", false);
```

## Enable configurable retry logic

[!INCLUDE [appliesto-netfx-netcore-netst-md](../../includes/appliesto-netfx-netcore-netst-md.md)]

(Available starting with version 3.0)

By default, configurable retry logic is disabled. To enable this feature, set the AppContext switch **Switch.Microsoft.Data.SqlClient.EnableRetryLogic** to `true` at application startup. This switch is required, even if a retry provider is assigned to a connection or command.

```csharp
AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.EnableRetryLogic", true);
```

* For information on how to enable the switch by using a configuration file see [Enable safety switch](configurable-retry-logic-config-file-sqlclient.md#enable-safety-switch).

> [!NOTE]
> Starting from Microsoft.Data.SqlClient v4.0, the App Context switch "Switch.Microsoft.Data.SqlClient.EnableRetryLogic" will no longer be required to use the configurable retry logic feature. The feature is now supported in production. The default behavior of the feature will continue to be a non-retry policy, which will need to be overridden by client applications to enable retries.

## Enabling rowversion null behavior

[!INCLUDE [appliesto-netfx-netcore-netst-md](../../includes/appliesto-netfx-netcore-netst-md.md)]
Expand Down
9 changes: 6 additions & 3 deletions docs/connect/ado-net/asynchronous-programming.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Asynchronous programming
description: Learn about asynchronous programming in the Microsoft SqlClient Data Provider for SQL Server.
author: David-Engel
ms.author: davidengel
ms.date: 12/04/2020
author: cheenamalhotra
ms.author: cmalhotra
ms.date: 08/19/2025
ms.service: sql
ms.subservice: connectivity
ms.topic: conceptual
Expand All @@ -29,6 +29,9 @@ The Microsoft SqlClient Data Provider for SQL Server includes methods from **Sys
> [!TIP]
> In the Microsoft SqlClient Data Provider for SQL Server, these legacy methods no longer require `Asynchronous Processing=true` in the connection string.

> [!WARNING]
> The `Asynchronous Processing` connection property is no longer supported in the Microsoft SqlClient Data Provider v4.0 onwards.

## Asynchronous programming features

These asynchronous programming features provide a simple technique to make code asynchronous.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,9 @@ Default retry logic options for an application can be changed by adding the foll
type="Microsoft.Data.SqlClient.SqlConfigurableRetryCommandSection, Microsoft.Data.SqlClient"/>
```

- `AppContextSwitchOverrides`: .NET Framework supports AppContext switches via an [AppContextSwitchOverrides](/dotnet/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element) section, which doesn't need to be defined explicitly. To turn on a switch in **.NET Core**, you must specify this section.

```csharp
<section name="AppContextSwitchOverrides"
type="Microsoft.Data.SqlClient.AppContextSwitchOverridesSection, Microsoft.Data.SqlClient"/>
```

> [!NOTE]
> The following configurations should be specified inside the `configuration` section. Declare these new sections to configure the default retry logic through an application configuration file.

### Enable safety switch

> [!NOTE]
> Starting from Microsoft.Data.SqlClient v4.0, the App Context switch "Switch.Microsoft.Data.SqlClient.EnableRetryLogic" will no longer be required to use the configurable retry logic feature. The feature is now supported in production. The default behavior of the feature will continue to be a non-retry policy, which will need to be overridden by client applications to enable retries.

You can enable the safety switch through a configuration file. To learn how to enable it through application code, see [Enable configurable retry logic](appcontext-switches.md#enable-configurable-retry-logic).

- **.NET Framework**: For more information, see [AppContextSwitchOverrides element](/dotnet/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element).

```csharp
<runtime>
<AppContextSwitchOverrides value="Switch.Microsoft.Data.SqlClient.EnableRetryLogic=true"/>
</runtime>
```

- **.NET Core**: supports multiple, semi-colon (;) delimited switches like .NET Framework.

```csharp
<AppContextSwitchOverrides value="Switch.Microsoft.Data.SqlClient.EnableRetryLogic=true"/>
```

### Connection section

The following attributes can be used to specify the default retry logic for all <xref:Microsoft.Data.SqlClient.SqlConnection> instances in an application:
Expand Down Expand Up @@ -159,7 +131,6 @@ The following attribute can also be set for all <xref:Microsoft.Data.SqlClient.S

## See also

- [Enable configurable retry logic](appcontext-switches.md#enable-configurable-retry-logic)
- [Internal retry logic providers in SqlClient](internal-retry-logic-providers-sqlclient.md)
- [Enable event tracing in SqlClient](enable-eventsource-tracing.md)
- [Specifying fully qualified type names](/dotnet/framework/reflection-and-codedom/specifying-fully-qualified-type-names)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ The implementation in this sample is as simple as possible to demonstrate step-b

[!code-csharp[SqlConfigurableRetryLogic_StepByStep_CustomProvider#3](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_StepByStep_CustomProvider.cs#3)]

> [!NOTE]
> Don't forget to enable the configurable retry logic switch before using it. For more information, see [Enable configurable retry logic](appcontext-switches.md#enable-configurable-retry-logic).

## See also

- [Microsoft.Data.SqlClient GitHub repository](https://github.com/dotnet/SqlClient/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,18 @@ This feature consists of three main components:

## Quick start

To use this feature, follow these four steps:
To use this feature, follow these steps:

1. Enable the safety switch in the preview version. For information on how to enable the AppContext safety switch, see [Enable configurable retry logic](appcontext-switches.md#enable-configurable-retry-logic).

2. Define the retry logic options using <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption>.
1. Define the retry logic options using <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption>.
In this sample, some of the retry parameters are set and the rest of them will use the default values.

[!code-csharp[SqlConfigurableRetryLogic_StepByStep_OpenConnection#1](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_StepByStep_OpenConnection.cs#1)]

3. Create a retry logic provider using your <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption> object.
2. Create a retry logic provider using your <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption> object.

[!code-csharp[SqlConfigurableRetryLogic_StepByStep_OpenConnection#2](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_StepByStep_OpenConnection.cs#2)]

4. Assign the <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> instance to the <xref:Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider%2A?displayProperty=nameWithType> or <xref:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider%2A?displayProperty=nameWithType>.
3. Assign the <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> instance to the <xref:Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider%2A?displayProperty=nameWithType> or <xref:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider%2A?displayProperty=nameWithType>.
In this sample, the connection open command will retry if it hits one of the transient errors in the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory> internal list for a maximum of five times.

[!code-csharp[SqlConfigurableRetryLogic_StepByStep_OpenConnection#3](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_StepByStep_OpenConnection.cs#3)]
Expand All @@ -53,6 +51,5 @@ In this sample, the connection open command will retry if it hits one of the tra
- [Configurable retry logic core APIs in SqlClient](configurable-retry-logic-core-apis-sqlclient.md)
- [Internal retry logic providers in SqlClient](internal-retry-logic-providers-sqlclient.md)
- [Configurable retry logic configuration file with SqlClient](configurable-retry-logic-config-file-sqlclient.md)
- [Enable configurable retry logic](appcontext-switches.md#enable-configurable-retry-logic)
- [Configurable retry logic in SqlClient](configurable-retry-logic.md)
- [Microsoft ADO.NET for SQL Server](microsoft-ado-net-sql-server.md)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Download Microsoft SqlClient Data Provider for SQL Server
description: Download page for ADO.NET and Microsoft SqlClient Data Provider for SQL Server.
author: cheenamalhotra
ms.author: cmalhotra
ms.date: 06/19/2025
ms.date: 08/19/2025
ms.service: sql
ms.subservice: connectivity
ms.topic: conceptual
Expand All @@ -22,6 +22,7 @@ For more information about version compatibility and support, see [SQL version c

## Download supported versions of Microsoft SqlClient Data Provider for SQL Server

* [6.1.1](https://www.nuget.org/packages/Microsoft.Data.SqlClient/6.1.1)
* [6.0.2](https://www.nuget.org/packages/Microsoft.Data.SqlClient/6.0.2)
* [5.2.3](https://www.nuget.org/packages/Microsoft.Data.SqlClient/5.2.3)
* [5.1.7](https://www.nuget.org/packages/Microsoft.Data.SqlClient/5.1.7)
Loading