![]() |
VOOZH | about |
Requires NuGet 2.12 or higher.
dotnet add package Microsoft.Data.SqlClient --version 7.0.1
NuGet\Install-Package Microsoft.Data.SqlClient -Version 7.0.1
<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.1" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.1" />Directory.Packages.props
<PackageReference Include="Microsoft.Data.SqlClient" />Project file
paket add Microsoft.Data.SqlClient --version 7.0.1
#r "nuget: Microsoft.Data.SqlClient, 7.0.1"
#:package Microsoft.Data.SqlClient@7.0.1
#addin nuget:?package=Microsoft.Data.SqlClient&version=7.0.1Install as a Cake Addin
#tool nuget:?package=Microsoft.Data.SqlClient&version=7.0.1Install as a Cake Tool
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.
This package supports:
Install the package via NuGet:
dotnet add package Microsoft.Data.SqlClient
Or via the Package Manager Console:
Install-Package Microsoft.Data.SqlClient
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!");
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 integrates with Azure.Identity to handle token acquisition, caching, and credential management.
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();
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)}");
}
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 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;
}
| 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+) |
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
| 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.
| 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 |
Two implementations are available:
Release notes are available at: https://go.microsoft.com/fwlink/?linkid=2090501
If you're migrating from System.Data.SqlClient, see the porting cheat sheet for guidance.
Key changes:
System.Data.SqlClient to Microsoft.Data.SqlClientMicrosoft.Data.SqlClientEncrypt=Mandatory is now the default)This package is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Microsoft.Data.SqlClient:
| Package | Downloads |
|---|---|
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core. |
|
|
AspNetCore.HealthChecks.SqlServer
HealthChecks.SqlServer is the health check package for SqlServer. |
|
|
Microsoft.Extensions.Caching.SqlServer
Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using Microsoft SQL Server. This package was built from the source code at https://github.com/dotnet/dotnet/tree/f7b4c5716faaee8fb8a289aed29118cad955c45f |
|
|
Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
NetTopologySuite support for the Microsoft SQL Server database provider for Entity Framework Core. |
|
|
Serilog.Sinks.MSSqlServer
A Serilog sink that writes events to Microsoft SQL Server and Azure SQL |
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.
|
|
|
mRemoteNG/mRemoteNG
mRemoteNG is the next generation of mRemote, open source, tabbed, multi-protocol, remote connections manager.
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
StockSharp/StockSharp
Algorithmic trading and quantitative trading open source platform to develop trading robots (stock markets, forex, crypto, bitcoins, and options).
|
|
|
nopSolutions/nopCommerce
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
|
|
|
HangfireIO/Hangfire
An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
|
|
|
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.
|
|
|
microsoft/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
|
|
|
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
|
| Version | Downloads | Last Updated |
|---|---|---|
| 7.1.0-preview1.26124.5 | 12,996 | 5/5/2026 |
| 7.0.1 | 4,526,206 | 4/24/2026 |
| 7.0.0 | 4,692,729 | 3/17/2026 |
| 7.0.0-preview4.26064.3 | 12,543 | 3/5/2026 |
| 7.0.0-preview3.25342.7 | 155,679 | 12/8/2025 |
| 7.0.0-preview2.25289.6 | 99,144 | 10/16/2025 |
| 7.0.0-preview1.25257.1 | 53,464 | 9/14/2025 |
| 6.1.5 | 599,060 | 4/27/2026 |
| 6.1.4 | 16,166,341 | 1/15/2026 |
| 6.1.3 | 13,647,289 | 11/12/2025 |
| 6.1.2 | 10,330,923 | 10/8/2025 |
| 6.1.1 | 39,522,610 | 8/14/2025 |
| 6.1.0-preview2.25178.5 | 101,581 | 6/27/2025 |
| 6.0.5 | 113,589 | 1/16/2026 |
| 6.0.4 | 95,739 | 11/15/2025 |
| 6.0.3 | 111,134 | 10/8/2025 |
| 5.1.9 | 149,502 | 1/13/2026 |
| 5.1.8 | 77,584 | 11/14/2025 |