Microsoft.Data.SqlClient
7.0.0.5705-ci
Prefix Reserved
Requires NuGet 2.12 or higher.
dotnet add package Microsoft.Data.SqlClient --version 7.0.0.5705-ci
NuGet\Install-Package Microsoft.Data.SqlClient -Version 7.0.0.5705-ci
<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.0.5705-ci" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.0.5705-ci" />
<PackageReference Include="Microsoft.Data.SqlClient" />
paket add Microsoft.Data.SqlClient --version 7.0.0.5705-ci
#r "nuget: Microsoft.Data.SqlClient, 7.0.0.5705-ci"
#:package Microsoft.Data.SqlClient@7.0.0.5705-ci
#addin nuget:?package=Microsoft.Data.SqlClient&version=7.0.0.5705-ci&prerelease
#tool nuget:?package=Microsoft.Data.SqlClient&version=7.0.0.5705-ci&prerelease
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 8.0+
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!");
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 |
| Azure AD Authentication | Multiple Azure Active Directory 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; |
| Azure AD Password | Authentication=Active Directory Password;User ID=user;Password=pass; |
| Azure AD Integrated | Authentication=Active Directory Integrated; |
| Azure AD Interactive | Authentication=Active Directory Interactive; |
| Azure AD Managed Identity | Authentication=Active Directory Managed Identity; |
| Azure AD Service Principal | Authentication=Active Directory Service Principal;User ID=clientId;Password=clientSecret; |
| Azure AD Default | Authentication=Active Directory Default; |
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
- Azure AD 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.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
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Bcl.Cryptography (>= 8.0.0)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.Extensions.Logging (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.SNI (>= 6.0.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.14.0)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.14.0)
- System.Buffers (>= 4.6.1)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- System.Memory (>= 4.6.3)
- System.Runtime.InteropServices.RuntimeInformation (>= 4.3.0)
- System.Security.Cryptography.Pkcs (>= 8.0.1)
- System.Text.Json (>= 8.0.6)
- System.Threading.Channels (>= 8.0.0)
- System.ValueTuple (>= 4.6.1)
-
.NETStandard 2.0
- Microsoft.Bcl.Cryptography (>= 8.0.0)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.Extensions.Logging (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.SNI.runtime (>= 6.0.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.14.0)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.14.0)
- Microsoft.SqlServer.Server (>= 1.0.0)
- System.Configuration.ConfigurationManager (>= 8.0.1)
- System.Security.Cryptography.Pkcs (>= 8.0.1)
- System.Text.Json (>= 8.0.6)
- System.Threading.Channels (>= 8.0.0)
-
net8.0
- Microsoft.Bcl.Cryptography (>= 8.0.0)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.Extensions.Logging (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.SNI.runtime (>= 6.0.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.14.0)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.14.0)
- Microsoft.SqlServer.Server (>= 1.0.0)
- System.Configuration.ConfigurationManager (>= 8.0.1)
- System.Security.Cryptography.Pkcs (>= 8.0.1)
-
net9.0
- Microsoft.Bcl.Cryptography (>= 9.0.9)
- Microsoft.Data.SqlClient.Extensions.Abstractions (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.Extensions.Logging (>= 1.0.0.5705-ci)
- Microsoft.Data.SqlClient.SNI.runtime (>= 6.0.2)
- Microsoft.Extensions.Caching.Memory (>= 9.0.9)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.14.0)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.14.0)
- Microsoft.SqlServer.Server (>= 1.0.0)
- System.Configuration.ConfigurationManager (>= 9.0.9)
- System.Security.Cryptography.Pkcs (>= 9.0.9)
GitHub repositories (266)
Showing the top 20 popular GitHub repositories that depend on Microsoft.Data.SqlClient:
| Repository | Stars |
|---|---|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
|
|
DapperLib/Dapper
Dapper - a simple object mapper for .Net
|
|
|
dotnet/efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
|
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
|
Sonarr/Sonarr
Smart PVR for newsgroup and bittorrent users.
|
|
|
Radarr/Radarr
Movie organizer/manager for usenet and torrent users.
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
mRemoteNG/mRemoteNG
mRemoteNG is the next generation of mRemote, open source, tabbed, multi-protocol, remote connections manager.
|
|
|
HangfireIO/Hangfire
An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
|
|
|
nopSolutions/nopCommerce
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
|
|
|
StockSharp/StockSharp
Algorithmic trading and quantitative trading open source platform to develop trading robots (stock markets, forex, crypto, bitcoins, and options).
|
|
|
TechnitiumSoftware/DnsServer
Technitium DNS Server
|
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
|
dotnetcore/CAP
Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
|
|
|
quartznet/quartznet
Quartz Enterprise Scheduler .NET
|
|
|
Prowlarr/Prowlarr
Prowlarr is an indexer manager/proxy built on the popular *arr .net/reactjs base stack to integrate with your various PVR apps, supporting management of both Torrent Trackers and Usenet Indexers.
|
|
|
Azure/azure-sdk-for-net
This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
|
|
|
danielgerlag/workflow-core
Lightweight workflow engine for .NET Standard
|
|
|
DotNetNext/SqlSugar
.Net aot ORM SqlServer ORM Mongodb ORM MySql 瀚高 Postgresql ORM DB2 Hana 高斯 Duckdb C# VB.NET Sqlite ORM Oracle ORM Mysql Orm 虚谷数据库 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET9 ORM .NET8 ORM ClickHouse ORM QuestDb ,TDengine ORM,OceanBase ORM,GaussDB ORM,Tidb ORM Object/Relational Mapping
|
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.0.5705-ci | 0 | 3/6/2026 |
| 7.0.0 | 0 | 3/12/2026 |