Microsoft.Data.SqlClient 8.0.0-preview1.26313.4
Microsoft.Data.SqlClient
Description
Microsoft.Data.SqlClient is the official .NET data provider for Microsoft SQL Server and Azure SQL databases. It provides access to SQL Server and encapsulates database-specific protocols, including Tabular Data Stream (TDS).
This library grew from a union of the two System.Data.SqlClient components which live independently in .NET and .NET Framework. Going forward, support for new SQL Server and Azure SQL features will only be implemented in Microsoft.Data.SqlClient.
Supportability
This package supports:
- .NET Framework 4.6.2+
- .NET 10.0+
The implementation targets net462;net10.0. Reference and unsupported-platform assemblies also
retain netstandard2.0; that target does not extend supported driver runtimes.
SqlClient family version validation
This package ships a consumer MSBuild target in build/ and buildTransitive/.
NuGet imports it for direct package consumers and transitive PackageReference
consumers. After package/reference resolution it compares installed
Microsoft.Data.SqlClient.Internal.Logging, Microsoft.Data.SqlClient.Extensions.Abstractions,
Microsoft.Data.SqlClient.Extensions.Azure, and
Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider package versions
against the resolved Microsoft.Data.SqlClient package version. Optional packages are
not required. Microsoft.SqlServer.Server and native SNI packages are excluded.
Versions must match exactly, including prerelease labels; a mismatch emits the
SQLCLIENT001 warning rather than failing the build by default. Upgrade all installed
family packages together.
Historical extensions numbered 1.0.0 are not mapped to driver 7.0.0/7.0.1.
The check uses resolved compile/runtime asset metadata for PackageReference and
installed versions in the active packages.config for legacy consumers. A
packages.<project-name>.config file takes precedence over packages.config;
spaces in the project name are replaced with underscores, matching NuGet.
It does not check assembly versions, restore ranges, or API compatibility. Assets
missing version metadata and builds without a Microsoft.Data.SqlClient version anchor
are skipped. Design-time builds are skipped.
To suppress the warning, set SqlClientEnforceFamilyVersions=false in the
consumer project or pass -p:SqlClientEnforceFamilyVersions=false. This disables
only this build check; it does not make mixed versions compatible. Excluding the
package's build assets also prevents target import. NuGet buildTransitive targets
can propagate through project-reference chains when a referenced project consumes
Microsoft.Data.SqlClient as a package. A direct project reference to SqlClient's
source project does not import its packaged targets, so this check does not enforce
in-tree Project-mode versions.
Installation
Install the package via NuGet:
dotnet add package Microsoft.Data.SqlClient
Or via the Package Manager Console:
Install-Package Microsoft.Data.SqlClient
Getting Started
Basic Connection
using Microsoft.Data.SqlClient;
var connectionString = "Server=myserver;Database=mydb;Integrated Security=true;";
using var connection = new SqlConnection(connectionString);
await connection.OpenAsync();
Console.WriteLine("Connected successfully!");
Connecting to Azure
Starting with v7.0, to use Entra ID authentication modes (such as Active Directory Default, Active Directory Managed Identity, Active Directory Interactive, etc.) via connection string keywords, install the Microsoft.Data.SqlClient.Extensions.Azure extension package via NuGet:
dotnet add package Microsoft.Data.SqlClient.Extensions.Azure
Or via the Package Manager Console:
Install-Package Microsoft.Data.SqlClient.Extensions.Azure
This package provides the ActiveDirectoryAuthenticationProvider, which uses Azure.Identity credential types supplied by Azure.Core to handle token acquisition, caching, and credential management.
The authentication registry and SqlAuthenticationInitializer now live in
Microsoft.Data.SqlClient.Extensions.Abstractions; existing driver type names are forwarded.
SqlAuthenticationProvider.GetProvider and SetProvider work directly without a reflective
bridge to the driver. Configuration registrations take precedence over application registrations,
which take precedence over discovered Azure defaults.
For explicit registration in trimmed and NativeAOT .NET 10 applications, disable reflective Azure
discovery and authentication app.config loading at publish time, then construct and register a
provider for each required method before opening connections. Trimmed JIT applications may retain
enabled reflection paths when they preserve the configuration infrastructure, handlers, providers,
initializers and discovered Azure contracts. Enabled paths report trimming/dynamic-code warnings.
They are not removed automatically. The switches
Switch.Microsoft.Data.SqlClient.EnableAppConfig and
Switch.Microsoft.Data.SqlClient.EnableAzureExtensionDiscovery default to true and are cached
on first access. Recoverable initialization failures emit diagnostic guidance through
Microsoft.Data.SqlClient.EventSource (Informational level, Trace keyword 0x2).
Recoverable bootstrap failures do not block explicit application registration or lookup of
usable registrations. Failed explicit methods cannot fall back to old/default providers;
initializer failure prevents defaults for otherwise-unregistered methods. Register a provider
as a workaround, or correct the cause and restart the application. Fatal bootstrap failures
propagate without being cached by the registry; later access can retry and repeat side effects
if execution continues. Detailed activation causes are not attached to the connection exception.
With this package reference, you can continue to use Entra ID authentication modes directly in your connection string:
// Active Directory Default — uses DefaultAzureCredential (Managed Identity, Azure CLI, Visual Studio, etc.)
var connectionString = "Server=myserver.database.windows.net;Database=mydb;Authentication=Active Directory Default;";
using var connection = new SqlConnection(connectionString);
await connection.OpenAsync();
Execute a Query
using Microsoft.Data.SqlClient;
var connectionString = "Server=myserver;Database=mydb;Integrated Security=true;";
using var connection = new SqlConnection(connectionString);
await connection.OpenAsync();
using var command = new SqlCommand("SELECT Id, Name FROM Customers", connection);
using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
Console.WriteLine($"Id: {reader.GetInt32(0)}, Name: {reader.GetString(1)}");
}
Parameterized Query
using Microsoft.Data.SqlClient;
var connectionString = "Server=myserver;Database=mydb;Integrated Security=true;";
using var connection = new SqlConnection(connectionString);
await connection.OpenAsync();
using var command = new SqlCommand("SELECT * FROM Customers WHERE Id = @id", connection);
command.Parameters.AddWithValue("@id", customerId);
using var reader = await command.ExecuteReaderAsync();
// Process results...
Using Transactions
using Microsoft.Data.SqlClient;
using var connection = new SqlConnection(connectionString);
await connection.OpenAsync();
using var transaction = connection.BeginTransaction();
try
{
using var command = new SqlCommand("INSERT INTO Orders (CustomerId, Total) VALUES (@customerId, @total)", connection, transaction);
command.Parameters.AddWithValue("@customerId", customerId);
command.Parameters.AddWithValue("@total", orderTotal);
await command.ExecuteNonQueryAsync();
await transaction.CommitAsync();
}
catch
{
await transaction.RollbackAsync();
throw;
}
Key Features
| Feature | Description |
|---|---|
| Cross-Platform | Runs on Windows, Linux, and macOS |
| Entra ID Authentication | Multiple Entra ID authentication modes |
| Always Encrypted | Client-side encryption for sensitive data |
| Connection Pooling | Efficient connection management |
| TLS 1.3 Support | Enhanced security with strict encryption mode |
| MARS | Multiple Active Result Sets on a single connection |
| Async Programming | Full async/await support |
| SqlBatch | Batch multiple commands for improved performance |
| JSON/Vector Support | Native support for JSON and Vector data types (SQL Server 2025+) |
Commonly Used Types
Microsoft.Data.SqlClient.SqlConnection
Microsoft.Data.SqlClient.SqlCommand
Microsoft.Data.SqlClient.SqlDataReader
Microsoft.Data.SqlClient.SqlParameter
Microsoft.Data.SqlClient.SqlTransaction
Microsoft.Data.SqlClient.SqlException
Microsoft.Data.SqlClient.SqlParameterCollection
Microsoft.Data.SqlClient.SqlClientFactory
Microsoft.Data.SqlClient.SqlBulkCopy
Microsoft.Data.SqlClient.SqlConnectionStringBuilder
Authentication Methods
| Method | Connection String |
|---|---|
| SQL Server Authentication | User ID=user;Password=pass; |
| Windows Authentication | Integrated Security=true; |
| Entra ID Password (deprecated) | Authentication=Active Directory Password;User ID=user;Password=pass; |
| Entra ID Integrated | Authentication=Active Directory Integrated; |
| Entra ID Interactive | Authentication=Active Directory Interactive; |
| Entra ID Managed Identity | Authentication=Active Directory Managed Identity; |
| Entra ID Service Principal | Authentication=Active Directory Service Principal;User ID=clientId;Password=clientSecret; |
| Entra ID Default | Authentication=Active Directory Default; |
| Entra ID Workload Identity | Authentication=Active Directory Workload Identity;User ID=clientId; |
Note: To use Entra ID authentication modes (such as
Active Directory Default,Active Directory Managed Identity,Active Directory Interactive, etc.) via connection string keywords, install the Microsoft.Data.SqlClient.Extensions.Azure extension package.
Encryption Modes
| Mode | Description |
|---|---|
Encrypt=Optional |
Encryption is used if available |
Encrypt=Mandatory |
Encryption is required (default) |
Encrypt=Strict |
TDS 8.0 with TLS 1.3 support |
SNI (SQL Server Network Interface)
Two implementations are available:
- Native SNI: Windows-only, provided via Microsoft.Data.SqlClient.SNI (.NET Framework) or Microsoft.Data.SqlClient.SNI.runtime (.NET on Windows)
- Managed SNI: Cross-platform managed implementation, used by default on Unix platforms
Documentation
- Microsoft.Data.SqlClient Documentation
- Connection String Syntax
- Connection Pooling
- Always Encrypted
- Entra ID Authentication
Release Notes
Release notes are available at: https://go.microsoft.com/fwlink/?linkid=2090501
Migrating from System.Data.SqlClient
If you're migrating from System.Data.SqlClient, see the porting cheat sheet for guidance.
Key changes:
- Change namespace from
System.Data.SqlClienttoMicrosoft.Data.SqlClient - Update package reference to
Microsoft.Data.SqlClient - Review connection string defaults (e.g.,
Encrypt=Mandatoryis now the default)
License
This package is licensed under the MIT License.
Related Packages
- Microsoft.Data.SqlClient.Extensions.Azure - Entra ID authentication provider using Azure.Core credentials
- Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider - Azure Key Vault integration for Always Encrypted
- Microsoft.SqlServer.Server - SQL CLR UDT support
- Microsoft.Data.SqlClient.SNI - Native SNI for .NET Framework
- Microsoft.Data.SqlClient.SNI.runtime - Native SNI runtime for .NET on Windows
Showing the top 20 packages that depend on Microsoft.Data.SqlClient.
| Packages | Downloads |
|---|---|
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
161 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
158 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
157 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
154 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
153 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
151 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
150 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
149 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
148 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
147 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
146 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
145 |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
|
144 |
.NET Framework 4.6.2
- Microsoft.Bcl.Cryptography (>= 10.0.13)
- Microsoft.Bcl.TimeProvider (>= 10.0.13)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 8.0.0-preview1.26313.4 && < 9.0.0)
- Microsoft.Data.SqlClient.Internal.Logging (>= 8.0.0-preview1.26313.4 && < 9.0.0)
- Microsoft.Data.SqlClient.SNI (>= 8.0.0-preview1.26309.4 && < 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- System.Buffers (>= 4.6.1)
- System.Data.Common (>= 4.3.0)
- System.Diagnostics.DiagnosticSource (>= 10.0.13)
- System.Memory (>= 4.6.3)
- System.Runtime.InteropServices.RuntimeInformation (>= 4.3.0)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
- System.Text.Json (>= 10.0.13)
- System.Threading.Channels (>= 10.0.13)
- System.Threading.RateLimiting (>= 10.0.13)
- System.ValueTuple (>= 4.6.2)
.NET 10.0
- Microsoft.Bcl.Cryptography (>= 10.0.13)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 8.0.0-preview1.26313.4 && < 9.0.0)
- Microsoft.Data.SqlClient.Internal.Logging (>= 8.0.0-preview1.26313.4 && < 9.0.0)
- Microsoft.Data.SqlClient.SNI.runtime (>= 8.0.0-preview1.26309.4 && < 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- Microsoft.SqlServer.Server (>= 1.0.0 && < 2.0.0)
- System.Configuration.ConfigurationManager (>= 10.0.13)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
- System.Threading.RateLimiting (>= 10.0.13)
.NET Standard 2.0
- Microsoft.Bcl.Cryptography (>= 10.0.13)
- Microsoft.Bcl.TimeProvider (>= 10.0.13)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 8.0.0-preview1.26313.4 && < 9.0.0)
- Microsoft.Data.SqlClient.Internal.Logging (>= 8.0.0-preview1.26313.4 && < 9.0.0)
- Microsoft.Data.SqlClient.SNI.runtime (>= 8.0.0-preview1.26309.4 && < 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- Microsoft.SqlServer.Server (>= 1.0.0 && < 2.0.0)
- System.Configuration.ConfigurationManager (>= 10.0.13)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
- System.Text.Json (>= 10.0.13)
- System.Threading.Channels (>= 10.0.13)
- System.Threading.RateLimiting (>= 10.0.13)
| Version | Downloads | Last updated |
|---|---|---|
| 8.0.0-preview1.26313.4 | 4 | 11/10/2026 |
| 7.1.1 | 22 | 10/2/2026 |
| 7.1.0 | 22 | 9/20/2026 |
| 7.1.0-preview3.26238.4 | 24 | 8/29/2026 |
| 7.1.0-preview2.26190.5 | 40 | 7/12/2026 |
| 7.1.0-preview2.26190.3 | 30 | 7/12/2026 |
| 7.1.0-preview1.26124.5 | 51 | 5/7/2026 |
| 7.0.3 | 22 | 9/12/2026 |
| 7.0.2 | 41 | 6/27/2026 |
| 7.0.1 | 46 | 5/4/2026 |
| 7.0.0 | 52 | 3/17/2026 |
| 7.0.0-preview4.26064.3 | 38 | 3/7/2026 |
| 7.0.0-preview3.25342.7 | 69 | 12/9/2025 |
| 7.0.0-preview2.25289.6 | 95 | 10/17/2025 |
| 7.0.0-preview1.25257.1 | 95 | 9/15/2025 |
| 6.1.8 | 12 | 10/29/2026 |
| 6.1.7 | 19 | 9/12/2026 |
| 6.1.6 | 48 | 6/27/2026 |
| 6.1.5 | 52 | 5/4/2026 |
| 6.1.4 | 43 | 1/16/2026 |
| 6.1.3 | 71 | 11/13/2025 |
| 6.1.2 | 93 | 10/8/2025 |
| 6.1.1 | 92 | 8/15/2025 |
| 6.1.0 | 139 | 7/26/2025 |
| 6.1.0-preview2.25178.5 | 88 | 7/3/2025 |
| 6.1.0-preview1.25120.4 | 109 | 5/2/2025 |
| 6.0.5 | 59 | 1/16/2026 |
| 6.0.4 | 85 | 11/16/2025 |
| 6.0.3 | 100 | 10/8/2025 |
| 6.0.2 | 111 | 4/28/2025 |
| 6.0.1 | 129 | 1/25/2025 |
| 6.0.0 | 126 | 1/16/2025 |
| 6.0.0-preview3.24332.3 | 99 | 11/28/2024 |
| 6.0.0-preview2.24304.8 | 136 | 11/2/2024 |
| 6.0.0-preview1.24240.8 | 109 | 8/29/2024 |
| 5.2.3 | 129 | 5/2/2025 |
| 5.2.2 | 120 | 8/27/2024 |
| 5.2.1 | 133 | 6/3/2024 |
| 5.2.0 | 149 | 2/29/2024 |
| 5.2.0-preview5.24024.3 | 130 | 1/30/2024 |
| 5.2.0-preview4.23342.2 | 121 | 12/12/2023 |
| 5.2.0-preview3.23201.1 | 130 | 7/31/2023 |
| 5.2.0-preview2.23159.1 | 147 | 7/1/2023 |
| 5.2.0-preview1.23109.1 | 130 | 5/14/2023 |
| 5.1.9 | 62 | 1/14/2026 |
| 5.1.8 | 71 | 11/14/2025 |
| 5.1.7 | 115 | 4/26/2025 |
| 5.1.6 | 139 | 8/27/2024 |
| 5.1.5 | 160 | 1/31/2024 |
| 5.1.4 | 154 | 1/28/2024 |
| 5.1.3 | 146 | 1/28/2024 |
| 5.1.2 | 131 | 10/29/2023 |
| 5.1.1 | 157 | 4/11/2023 |
| 5.1.0 | 126 | 2/5/2023 |
| 5.1.0-preview2.22314.2 | 128 | 11/18/2022 |
| 5.1.0-preview1.22279.3 | 141 | 10/28/2022 |
| 5.0.2 | 135 | 6/15/2023 |
| 5.0.1 | 148 | 11/13/2022 |
| 5.0.0 | 158 | 9/4/2022 |
| 5.0.0-preview3.22168.1 | 134 | 6/23/2022 |
| 5.0.0-preview2.22096.2 | 137 | 6/27/2022 |
| 5.0.0-preview1.22069.1 | 142 | 6/27/2022 |
| 4.1.1 | 138 | 9/15/2022 |
| 4.1.0 | 143 | 6/27/2022 |
| 4.0.6 | 113 | 8/26/2024 |
| 4.0.5 | 140 | 1/22/2024 |
| 4.0.4 | 155 | 10/30/2023 |
| 4.0.3 | 145 | 7/31/2023 |
| 4.0.2 | 127 | 9/15/2022 |
| 4.0.1 | 167 | 6/27/2022 |
| 4.0.0 | 140 | 6/16/2022 |
| 4.0.0-preview3.21293.2 | 136 | 6/27/2022 |
| 4.0.0-preview2.21264.2 | 140 | 6/27/2022 |
| 4.0.0-preview1.21237.2 | 151 | 6/27/2022 |
| 3.1.7 | 131 | 8/21/2024 |
| 3.1.6 | 139 | 8/17/2024 |
| 3.1.5 | 138 | 1/28/2024 |
| 3.1.4 | 141 | 11/5/2023 |
| 3.1.3 | 149 | 7/31/2023 |
| 3.1.2 | 131 | 2/23/2023 |
| 3.1.1 | 140 | 9/15/2022 |
| 3.1.0 | 164 | 6/27/2022 |
| 3.0.1 | 147 | 6/27/2022 |
| 3.0.0 | 136 | 6/16/2022 |
| 3.0.0-preview3.21140.5 | 137 | 6/27/2022 |
| 3.0.0-preview2.21106.5 | 147 | 6/27/2022 |
| 3.0.0-preview1.21075.2 | 133 | 6/24/2022 |
| 2.1.7 | 130 | 1/28/2024 |
| 2.1.6 | 130 | 6/12/2023 |
| 2.1.5 | 136 | 9/10/2022 |
| 2.1.4 | 146 | 6/24/2022 |
| 2.1.3 | 120 | 6/27/2022 |
| 2.1.2 | 132 | 6/27/2022 |
| 2.1.1 | 148 | 6/16/2022 |
| 2.1.0 | 140 | 6/27/2022 |
| 2.1.0-preview2.20297.7 | 120 | 6/27/2022 |
| 2.1.0-preview1.20235.1 | 141 | 6/27/2022 |
| 2.0.1 | 146 | 6/27/2022 |
| 2.0.0 | 142 | 6/27/2022 |
| 2.0.0-preview4.20142.4 | 124 | 6/27/2022 |
| 2.0.0-preview3.20122.2 | 142 | 6/27/2022 |
| 2.0.0-preview2.20084.1 | 136 | 6/27/2022 |
| 2.0.0-preview1.20021.1 | 142 | 6/27/2022 |
| 1.1.4 | 147 | 6/27/2022 |
| 1.1.3 | 135 | 6/27/2022 |
| 1.1.2 | 154 | 6/27/2022 |
| 1.1.1 | 129 | 6/27/2022 |
| 1.1.0 | 147 | 6/27/2022 |
| 1.1.0-preview2.19309.1 | 137 | 6/27/2022 |
| 1.1.0-preview1.19275.1 | 147 | 6/26/2022 |
| 1.0.19269.1 | 128 | 6/27/2022 |
| 1.0.19249.1 | 137 | 6/13/2022 |
| 1.0.19239.1 | 122 | 6/27/2022 |
| 1.0.19221.1-Preview | 146 | 6/27/2022 |
| 1.0.19189.1-Preview | 127 | 6/27/2022 |
| 1.0.19128.1-Preview | 132 | 6/27/2022 |
| 1.0.19123.2-Preview | 150 | 6/27/2022 |