# dotnet/sqlclient architecture

> Architecture diagram of the GitHub repository dotnet/sqlclient, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dotnet/sqlclient
- Repository: https://github.com/dotnet/sqlclient
- Video tour (about a minute): https://gitdiagram.com/dotnet/sqlclient/video

## Overview

Microsoft.Data.SqlClient is a .NET data provider for SQL Server and Azure SQL. The primary workflow is an application opening a connection, issuing database work, and consuming results; the README establishes the provider’s role, but the excerpts do not show the full command-to-TDS call chain. The graph also preserves authentication and Always Encrypted capabilities. Connections beyond explicit README or SOURCE INDEX references are omitted; unsampled implementation details are represented only where the tree or CORE MODULES line identifies them.

Main entry points: [`src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs`](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs) (Azure authentication), [`src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs`](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs) (Azure Key Vault provider), [`src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs`](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs) (SQL connection), [`src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs`](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs) (Authentication manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_provider["Provider runtime"]
  node_connection["SQL connection<br/>[SqlConnection.cs]"]
  node_command["Command execution"]
  node_reader["Data reader<br/>[SqlDataReader.cs]"]
  node_bulk["Bulk copy<br/>[SqlBulkCopy.cs]"]
  node_transaction["Transactions<br/>[SqlTransaction.cs]"]
end

subgraph group_transport["Connection and protocol"]
  node_pool["Connection pooling"]
  node_internal_connection["Internal connection"]
  node_tds_parser["TDS parser<br/>[TdsParser.cs]"]
  node_tds_state["TDS state"]
  node_managed_sni["Managed SNI"]
end

subgraph group_security["Authentication and encryption"]
  node_auth_manager["Authentication manager"]
  node_column_keys["Column key providers"]
end

subgraph group_extensions["Provider extensions"]
  node_auth_abstractions["Authentication abstractions"]
  node_auth_method["Authentication methods"]
  node_auth_token["Authentication token"]
  node_azure_auth["Azure authentication"]
  node_akv_provider["Azure Key Vault provider"]
  node_key_crypto["Key cryptography"]
  node_key_cache[("Key cache<br/>[LocalCache.cs]")]
end

node_app(("Application"))
node_server[("SQL Server / Azure SQL")]

node_app -->|"opens connection"| node_connection
node_connection -->|"connects to"| node_server
node_auth_manager -->|"loads provider"| node_azure_auth
node_azure_auth -->|"uses methods"| node_auth_method
node_azure_auth -->|"uses parameters"| node_auth_abstractions
node_azure_auth -->|"returns tokens"| node_auth_token
node_akv_provider -->|"delegates crypto"| node_key_crypto
node_akv_provider -->|"uses cache"| node_key_cache
node_akv_provider -->|"implements provider"| node_column_keys

click node_connection "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs"
click node_command "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.NonQuery.cs"
click node_reader "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs"
click node_bulk "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs"
click node_transaction "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlTransaction.cs"
click node_pool "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs"
click node_internal_connection "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs"
click node_tds_parser "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs"
click node_tds_state "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs"
click node_managed_sni "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniProviders.netcore.cs"
click node_auth_manager "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs"
click node_auth_abstractions "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationParameters.cs"
click node_auth_method "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationMethod.cs"
click node_auth_token "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationToken.cs"
click node_azure_auth "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs"
click node_column_keys "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionKeyStoreProvider.cs"
click node_akv_provider "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs"
click node_key_crypto "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/AzureSqlKeyCryptographer.cs"
click node_key_cache "https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/LocalCache.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_connection,node_command,node_reader,node_bulk,node_transaction toneBlue
class node_pool,node_internal_connection,node_tds_parser,node_tds_state,node_managed_sni,node_server toneAmber
class node_auth_manager,node_column_keys toneMint
class node_auth_abstractions,node_auth_method,node_auth_token,node_azure_auth,node_akv_provider,node_key_crypto,node_key_cache toneRose
class node_app toneIndigo
```

## Components

### Provider runtime

- [SQL connection](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs`
- [Command execution](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.NonQuery.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.NonQuery.cs`
- [Data reader](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs`
- [Bulk copy](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs`
- [Transactions](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlTransaction.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlTransaction.cs`

### Connection and protocol

- [Connection pooling](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs`
- [Internal connection](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs`
- [TDS parser](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs`
- [TDS state](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs`
- [Managed SNI](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniProviders.netcore.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniProviders.netcore.cs`

### Authentication and encryption

- [Authentication manager](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs`
- [Column key providers](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionKeyStoreProvider.cs): `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionKeyStoreProvider.cs`

### Provider extensions

- [Authentication abstractions](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationParameters.cs): `src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationParameters.cs`
- [Authentication methods](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationMethod.cs): `src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationMethod.cs`
- [Authentication token](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationToken.cs): `src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationToken.cs`
- [Azure authentication](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs): `src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs`
- [Azure Key Vault provider](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs): `src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs`
- [Key cryptography](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/AzureSqlKeyCryptographer.cs): `src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/AzureSqlKeyCryptographer.cs`
- [Key cache](https://github.com/dotnet/sqlclient/blob/main/src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/LocalCache.cs): `src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/LocalCache.cs`

### Other components

- **Application**
- **SQL Server / Azure SQL**

## Connections

- Application → SQL connection: opens connection (evidence: `README.md`)
- SQL connection → SQL Server / Azure SQL: connects to (evidence: `README.md`)
- Authentication manager → Azure authentication: loads provider (evidence: `src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs`)
- Azure authentication → Authentication methods: uses methods (evidence: `src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs`)
- Azure authentication → Authentication abstractions: uses parameters (evidence: `src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs`)
- Azure authentication → Authentication token: returns tokens (evidence: `src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs`)
- Azure Key Vault provider → Key cryptography: delegates crypto (evidence: `src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs`)
- Azure Key Vault provider → Key cache: uses cache (evidence: `src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs`)
- Azure Key Vault provider → Column key providers: implements provider (evidence: `src/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider/src/SqlColumnEncryptionAzureKeyVaultProvider.cs`)
