Microsoft.Data.SqlClient: How to Install and Update It on Windows

Share

NuGet Gallery page for Microsoft.Data.SqlClient showing the package name, supported frameworks and the dotnet add package install command

Microsoft.Data.SqlClient on NuGet, the official place to get it. Screenshot from nuget.org, October 2026.

Microsoft.Data.SqlClient is Microsoft’s free library that lets .NET apps on Windows talk to SQL Server and Azure SQL databases, available as a package from NuGet. There is no installer to download. You add it to your project in Visual Studio or with one command.

It replaced the older System.Data.SqlClient, which Microsoft has deprecated. New SQL Server and Azure SQL features only arrive in Microsoft.Data.SqlClient. It works in .NET 8 and later, and in .NET Framework 4.6.2 and later.

This page used to cover version 2.0.0 from 2020, which lost support in May 2021. It now covers the supported versions and how to move up from an old one.

Below: which version to pick, three ways to install it, a first connection in C#, and the changes that trip up upgrades. Questions? Reach out to us directly.

Made by
Microsoft
Price
Free, MIT license
Works with
.NET 8+, .NET Framework 4.6.2+
Get it from
NuGet

What Is Microsoft.Data.SqlClient?

It is a data provider: the piece of code that opens a connection to the database, sends your SQL and reads back the results. You use classes such as SqlConnection, SqlCommand and SqlDataReader, the same names .NET developers have used for years.

Microsoft ships it on NuGet, separately from .NET itself, so it can add support for new database features without waiting for a new .NET release. Entity Framework Core’s SQL Server provider is built on top of it.

It connects to SQL Server 2017 and later, Azure SQL Database, Azure SQL Managed Instance, Azure Synapse Analytics and SQL databases in Microsoft Fabric.

Looking for version 2.0.0?

Version 2.0 came out in June 2020 and its support ended on May 19, 2021. It gets no security fixes. You can still pin it on NuGet if an old project needs it, but plan an upgrade. The newest stable version when we checked in October 2026 was 7.1.1.

Which Version Should You Use?

Microsoft runs two kinds of release. Long-Term Support (LTS) lines get three years of fixes. Standard-Term Support (STS) lines are supported until three months after the next release.

Supported Versions
From Microsoft’s SqlClient support lifecycle page. Checked October 2026
Line Support type First released Support ends
7.1 STS September 17, 2026 Three months after the next release
7.0 STS March 17, 2026 December 17, 2026
6.1 LTS August 14, 2025 August 14, 2028

Simple rule: pick the newest line for a new project, or the LTS line if you upgrade rarely. Always use the latest patch in the line you choose. Microsoft keeps the current table on its support lifecycle page.

How to Install Microsoft.Data.SqlClient

Pick whichever fits how you work. All three add the same package to your project.

VISUAL STUDIO

NuGet Package Manager

In Visual Studio, right-click your project in Solution Explorer and select Manage NuGet Packages.

On the Browse tab, search for Microsoft.Data.SqlClient, pick the version and select Install. The screenshot shows the same screen with another package.

Visual Studio NuGet Package Manager Browse tab with a search box, package list, version picker and Install button

.NET CLI

In a terminal, inside your project folder:

dotnet add package Microsoft.Data.SqlClient

Package Manager Console

In Visual Studio, under Tools, NuGet Package Manager:

Install-Package Microsoft.Data.SqlClient

Signing in with Microsoft Entra ID? From version 7.0, the Active Directory sign-in modes need a second package: Microsoft.Data.SqlClient.Extensions.Azure. Install the same version as the main package.

Your First Connection in C#

This short example opens a connection, runs one query and prints the result. Swap in your own server and database names.

using Microsoft.Data.SqlClient;

var cs = "Server=myserver.database.windows.net;Database=mydb;Authentication=Active Directory Default;Encrypt=True;";

await using var conn = new SqlConnection(cs);
await conn.OpenAsync();

await using var cmd = new SqlCommand("SELECT @@VERSION", conn);
Console.WriteLine(await cmd.ExecuteScalarAsync());

The connection string above signs in with Microsoft Entra ID, so it needs the Extensions.Azure package. For a local SQL Server with Windows sign-in, use Integrated Security=True instead of the Authentication setting.

Never put a password in your code. Use Microsoft Entra ID, Windows sign-in or a managed identity where you can. Microsoft marks the Active Directory Password mode as obsolete from version 7.0.

Upgrading From an Old Version

Coming from 2.0 or another old release? Three changes cause most upgrade problems. Check each one your jump crosses.

Changes That Break Old Apps
From Microsoft’s release notes
Version What changed What to do
4.0 Connections are encrypted by default and the server certificate is checked Install a trusted certificate on the server. Use TrustServerCertificate=True only for local testing
5.0 The Encrypt setting changed from true or false to an option type, and Encrypt=Strict was added Rebuild code that sets SqlConnectionStringBuilder.Encrypt
7.0 Microsoft Entra sign-in moved to a separate package Add Microsoft.Data.SqlClient.Extensions.Azure if you use an Active Directory sign-in mode
UPDATE

Update the package in Visual Studio

Open Manage NuGet Packages and select the Updates tab. Pick Microsoft.Data.SqlClient, choose the version and select Update.

Update any companion packages, such as Extensions.Azure, to the same version at the same time. Then test sign-in, encryption and anything that uses transactions.

Visual Studio NuGet Package Manager Updates tab with a package selected and the Update button next to the latest stable version

From the command line, running the install command again moves the project to the latest stable version:

dotnet add package Microsoft.Data.SqlClient

Moving From System.Data.SqlClient

Microsoft deprecated the System.Data.SqlClient package in August 2024. Its NuGet page now says to use Microsoft.Data.SqlClient instead.

1 Add the Microsoft.Data.SqlClient package to your project.

2 Remove the System.Data.SqlClient package, so the two are never mixed in one app. Their classes share names but are not interchangeable.

3 Change using System.Data.SqlClient to using Microsoft.Data.SqlClient in your code.

4 Test connections carefully. Encryption is on by default in the new provider, so servers without a trusted certificate will refuse to connect until you fix that.

Microsoft’s full checklist is in its migration guide. If you manage SQL Server from Windows, our guide to Azure Data Studio and its replacements covers SSMS and the VS Code MSSQL extension.

Open Source on GitHub

GITHUB

Built in the open

Microsoft.Data.SqlClient is open source under the MIT license. The code, release notes for every version and the issue tracker live in the dotnet/SqlClient repository.

Found a bug? Search the issues there first, since many upgrade problems already have an answer.

The dotnet SqlClient repository on GitHub with its folders, MIT license and latest stable release

Frequently Asked Questions

Is Microsoft.Data.SqlClient free?
Yes. It is free and open source under the MIT license, and you can use it in commercial apps.
Does Microsoft.Data.SqlClient work on Linux and macOS?
Yes, for apps on .NET 8 or later. .NET Framework apps run on Windows only.
Why do I get a certificate chain error after upgrading?
From version 4.0, connections are encrypted by default and the server certificate must be trusted. Install a certificate the client trusts and connect using the name on that certificate. Setting TrustServerCertificate=True hides the error, but use it only for local testing.
What does Cannot find an authentication provider for ActiveDirectoryDefault mean?
Your app uses Microsoft Entra sign-in on version 7.0 or later without the Microsoft.Data.SqlClient.Extensions.Azure package. Install that package at the same version as the main package.
Do I need it if I use Entity Framework Core?
The EF Core SQL Server provider already depends on Microsoft.Data.SqlClient, so it comes along automatically. Add it directly only when you want a newer version or call it from your own code.

Support and Community

More Windows software guides: Azure Data Studio Replacements · What Is Microsoft Azure? · Azure PowerShell · Azure Mandatory MFA


Discover more from Windows Mode

Subscribe to get the latest posts sent to your email.