Microsoft.Data.SqlClient 7.0.0-preview4.26064.3

Microsoft.Data.SqlClient

NuGet NuGet Downloads

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:

Documentation

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:

  1. Change namespace from System.Data.SqlClient to Microsoft.Data.SqlClient
  2. Update package reference to Microsoft.Data.SqlClient
  3. Review connection string defaults (e.g., Encrypt=Mandatory is now the default)

License

This package is licensed under the MIT License.

Showing the top 20 packages that depend on Microsoft.Data.SqlClient.

Packages Downloads
Z.Expressions.Eval
C# Eval Expression is an Eval function. You can Evaluate, Compile and Execute C# code at runtime. Example: https://dotnetfiddle.net/COq6FC Include free and prime features.
18
learun.database
力软数据库操作方法 3.4.6 添加表名插入数据方法 3.4.8 修复表名插入数据方法字段类型错误的问题 3.4.9 添加表名更新数据方法 和 删除方法 3.5.0 修复表名更新方法错误问题 3.5.1 mysql 连接测试异常 3.5.2 增加新的查询方法
18
SqlSugarCore
.Net Core3.1 .Net5 .Net6 .Net7 .Net8 .net9 安装此版本,好用的ORM框架 ,支持国外主流和国产人大金仓达梦 OceanBase GaussDB QuestDb ClickHouse Oracle MySql Gbase8s SqlServer Sqlite DB2 DuckDb Hana 等, 使用教程:https://www.donet5.com/Home/Doc?typeId=1226
17
learun.database
力软数据库操作方法 3.4.6 添加表名插入数据方法 3.4.8 修复表名插入数据方法字段类型错误的问题 3.4.9 添加表名更新数据方法 和 删除方法 3.5.0 修复表名更新方法错误问题 3.5.1 mysql 连接测试异常 3.5.2 增加新的查询方法
17
SqlSugarCore
.Net Core3.1 .Net5 .Net6 .Net7 .Net8 .net9 安装此版本,好用的ORM框架 ,支持国外主流和国产人大金仓达梦 OceanBase GaussDB QuestDb ClickHouse Oracle MySql Gbase8s SqlServer Sqlite DB2 DuckDb Hana 等, 使用教程:https://www.donet5.com/Home/Doc?typeId=1226
16
SqlSugarCore
好用的ORM框架 .Net Core .NetT3.1 .Net7 .Net8 安装此版本,支持国外主流和国产人大金仓达梦 OceanBase GaussDB QuestDb ClickHouse Oracle MySql SqlServer Sqlite, 版本说明: 5.0.3.5-Max 最低要求.Net Core 3.0+ ,5.0.0-5.0.3.4 最低要求 .Net Core 2.0+ SqlSugar ORM ,High-performance, lightweight
16
SqlSugarCore
.Net Core3.1 .Net5 .Net6 .Net7 .Net8 .net9 安装此版本,好用的ORM框架 ,支持国外主流和国产人大金仓达梦 OceanBase GaussDB QuestDb ClickHouse Oracle MySql Gbase8s SqlServer Sqlite DB2 DuckDb Hana 等, 使用教程:https://www.donet5.com/Home/Doc?typeId=1226
15
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/aspnetcore/tree/63d1187a01b82719c2891cecc74ee3d51ce892a8
15
SqlSugarCore
好用的ORM框架 .Net Core .Net5 .Net6 .Net7 安装此版本,支持国外主流和国产人大金仓达梦, 版本说明: 5.0.3.5-Max 最低要求.Net Core 3.0+ ,5.0.0-5.0.3.4 最低要求 .Net Core 2.0+ SqlSugar ORM ,High-performance, lightweight
15
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core.
15
SqlSugarCore
.Net Core .Net5 .Net6 .Net7 安装此版本, 版本说明: 5.0.3.5-Max 最低要求.Net Core 3.0+ ,5.0.0-5.0.3.4 最低要求 .Net Core 2.0+ SqlSugar ORM ,High-performance, lightweight
15
learun.database
力软数据库操作方法 3.4.6 添加表名插入数据方法 3.4.8 修复表名插入数据方法字段类型错误的问题 3.4.9 添加表名更新数据方法 和 删除方法 3.5.0 修复表名更新方法错误问题 3.5.1 mysql 连接测试异常 3.5.2 增加新的查询方法
15
SqlSugarCore
好用的ORM框架 .Net Core .Net5 .Net6 .Net7 安装此版本,支持国外主流和国产人大金仓达梦 QuestDb ClickHouse Oracle MySql SqlServer Sqlite, 版本说明: 5.0.3.5-Max 最低要求.Net Core 3.0+ ,5.0.0-5.0.3.4 最低要求 .Net Core 2.0+ SqlSugar ORM ,High-performance, lightweight
15
SqlSugarCore
.Net Core3.1 .Net5 .Net6 .Net7 .Net8 .net9 安装此版本,好用的ORM框架 ,支持国外主流和国产人大金仓达梦 OceanBase GaussDB QuestDb ClickHouse Oracle MySql Gbase8s SqlServer Sqlite DB2 DuckDb Hana 等, 使用教程:https://www.donet5.com/Home/Doc?typeId=1226
14
learun.database
力软数据库操作方法 3.4.6 添加表名插入数据方法 3.4.8 修复表名插入数据方法字段类型错误的问题 3.4.9 添加表名更新数据方法 和 删除方法 3.5.0 修复表名更新方法错误问题 3.5.1 mysql 连接测试异常 3.5.2 增加新的查询方法
14
SqlSugarCore
.Net Core3.1 .Net5 .Net6 .Net7 .Net8 安装此版本,好用的ORM框架 ,支持国外主流和国产人大金仓达梦 OceanBase GaussDB QuestDb ClickHouse Oracle MySql Gbase8s SqlServer Sqlite 等, 使用教程:https://www.donet5.com/Home/Doc?typeId=1226
14

https://go.microsoft.com/fwlink/?linkid=2090501

.NET Framework 4.6.2

.NET 9.0

.NET Standard 2.0

.NET 8.0

Version Downloads Last updated
7.0.0 0 2026/3/17
7.0.0-preview4.26064.3 1 2026/3/10
7.0.0-preview3.25342.7 6 2026/1/1
7.0.0-preview2.25289.6 8 2025/11/4
7.0.0-preview1.25257.1 6 2025/9/23
6.1.4 3 2026/2/8
6.1.3 13 2025/11/20
6.1.2 7 2025/10/9
6.1.1 7 2025/9/23
6.1.0-preview2.25178.5 6 2025/9/23
6.1.0-preview1.25120.4 4 2025/5/25
6.0.5 5 2026/1/18
6.0.4 8 2025/11/22
6.0.3 9 2025/10/9
6.0.2 2 2025/5/27
6.0.1 1 2025/5/27
6.0.0-preview3.24332.3 1 2025/5/27
6.0.0-preview2.24304.8 2 2025/5/27
6.0.0-preview1.24240.8 6 2025/5/27
5.2.3 9 2025/5/25
5.2.2 11 2025/4/27
5.2.1 6 2025/5/27
5.2.0 5 2025/5/27
5.2.0-preview5.24024.3 8 2025/5/27
5.2.0-preview4.23342.2 6 2025/5/27
5.2.0-preview3.23201.1 10 2025/5/27
5.2.0-preview2.23159.1 7 2025/5/28
5.2.0-preview1.23109.1 6 2025/5/27
5.1.9 3 2026/2/8
5.1.8 4 2025/11/21
5.1.7 6 2025/5/27
5.1.6 10 2025/5/27
5.1.5 5 2025/5/27
5.1.4 6 2025/5/28
5.1.3 6 2025/5/27
5.1.2 8 2025/5/27
5.1.1 6 2025/5/27
5.1.0 5 2025/5/27
5.1.0-preview2.22314.2 6 2025/5/27
5.1.0-preview1.22279.3 8 2025/5/27
5.0.2 7 2025/5/27
5.0.1 8 2025/5/27
5.0.0 7 2025/4/27
5.0.0-preview3.22168.1 8 2025/5/27
5.0.0-preview2.22096.2 7 2025/5/27
5.0.0-preview1.22069.1 6 2025/5/27
4.1.1 7 2025/5/27
4.1.0 5 2025/5/27
4.0.6 6 2025/5/27
4.0.5 5 2025/5/27
4.0.4 7 2025/5/27
4.0.3 7 2025/5/27
4.0.2 5 2025/5/27
4.0.1 5 2025/5/27
4.0.0 6 2025/5/27
4.0.0-preview3.21293.2 7 2025/5/27
4.0.0-preview2.21264.2 6 2025/5/27
4.0.0-preview1.21237.2 8 2025/5/27
3.1.7 5 2025/5/27
3.1.6 2 2026/2/9
3.1.5 5 2025/5/27
3.1.4 6 2025/5/27
3.1.3 9 2025/5/27
3.1.2 5 2025/5/27
3.1.1 8 2025/5/27
3.1.0 5 2025/5/27
3.0.1 5 2025/5/28
3.0.0 7 2025/5/27
3.0.0-preview3.21140.5 8 2025/5/28
3.0.0-preview2.21106.5 6 2025/5/27
3.0.0-preview1.21075.2 6 2025/5/27
2.1.7 6 2025/5/28
2.1.6 5 2025/5/27
2.1.5 6 2025/5/27
2.1.4 6 2025/5/27
2.1.3 7 2025/5/27
2.1.2 5 2025/5/28
2.1.1 6 2025/5/27
2.1.0 5 2025/5/27
2.1.0-preview2.20297.7 6 2025/5/28
2.1.0-preview1.20235.1 9 2025/5/27
2.0.1 6 2025/5/27
2.0.0 6 2025/5/27
2.0.0-preview4.20142.4 7 2025/5/27
2.0.0-preview3.20122.2 8 2025/5/27
2.0.0-preview2.20084.1 7 2025/5/27
2.0.0-preview1.20021.1 7 2025/5/27
1.1.4 6 2025/5/27
1.1.3 6 2025/5/27
1.1.2 5 2025/5/27
1.1.1 5 2025/5/27
1.1.0 6 2025/5/27
1.1.0-preview2.19309.1 6 2025/5/27
1.1.0-preview1.19275.1 5 2025/5/27
1.0.19269.1 6 2025/5/27
1.0.19249.1 6 2025/5/28
1.0.19239.1 6 2025/5/27
1.0.19221.1-Preview 6 2025/5/27
1.0.19189.1-Preview 6 2025/5/27
1.0.19128.1-Preview 6 2025/5/27
1.0.19123.2-Preview 8 2025/5/27