Sitelet https://github.com/dotnet/SqlClient/pull/3005
Skip to content

Feature | Implement SqlConnection.GetSchemaAsync - #3005

Merged
paulmedynski merged 17 commits into
dotnet:mainfrom
edwardneal:issue-646
May 5, 2026
Merged

paulmedynski merged 17 commits into
dotnet:mainfrom
edwardneal:issue-646

Conversation

@edwardneal

@edwardneal edwardneal commented Nov 14, 2024 •

Copy link
Copy Markdown
Contributor

Contributes to #646, adding SqlConnection.GetSchemaAsync.

I can't add the IDbColumnSchemaGenerator method because the .NET Framework version of SqlDataReader doesn't yet implement that interface. #2967 tracks this. SqlDataReader.GetSchemaTableAsync requires some extra work with the state machine to guarantee that the column metadata is available, and I'll submit a separate PR for this.

I've added some basic documentation, but this effectively follows the SqlCommand.[Something]Async pattern of "An asynchronous version of [Something], which <etc.>"

I've also moved the netfx GetSchema methods from SqlConnectionHelper.cs to SqlConnection.cs, to align that part of it with netcore. This contributes to the merge slightly.

Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbMetaDataFactory.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbMetaDataFactory.cs Outdated
@codecov

codecov Bot commented Nov 14, 2024 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.48%. Comparing base (62d96ad) to head (c427e64).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...ient/src/Microsoft/Data/SqlClient/SqlConnection.cs 90.00% 1 Missing ⚠️
...src/Microsoft/Data/SqlClient/SqlMetaDataFactory.cs 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3005      +/-   ##
==========================================
- Coverage   66.02%   64.48%   -1.55%     
==========================================
  Files         277      271       -6     
  Lines       42989    65791   +22802     
==========================================
+ Hits        28383    42423   +14040     
- Misses      14606    23368    +8762     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 64.48% <95.12%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edwardneal edwardneal changed the title Implement SqlConnection.GetSchemaAsync Implement SqlConnection.GetSchemaAsync and SqlDataReader.GetSchemaTableAsync Nov 15, 2024
@edwardneal
edwardneal marked this pull request as draft November 15, 2024 22:38
This introduces async-over-sync, removing such requires work with the state machine and separate review.
@edwardneal
edwardneal marked this pull request as ready for review November 16, 2024 08:56
@edwardneal edwardneal changed the title Implement SqlConnection.GetSchemaAsync and SqlDataReader.GetSchemaTableAsync Implement SqlConnection.GetSchemaAsync Nov 16, 2024
@mdaigle mdaigle added 💡 Enhancement Public API 🆕 Issues/PRs that introduce new APIs to the driver. labels Nov 25, 2024
@paulmedynski

Copy link
Copy Markdown
Contributor

@edwardneal - Can you resolve the conflicts, and then I will kick off another CI run?

@edwardneal
edwardneal requested a review from a team as a code owner July 2, 2025 21:14
@edwardneal

Copy link
Copy Markdown
Contributor Author

Thanks @paulmedynski, I've just brought the branch up to date.

@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski paulmedynski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few inconsistencies and questions.

Comment thread doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml Outdated
Comment thread src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs Outdated
@paulmedynski
paulmedynski requested a review from a team July 4, 2025 10:20
Remove SqlDataReader.GetSchemaTableAsync (and references to such.)
Expand test coverage of both GetSchema and GetSchemaAsync.
Correct typo in documentation for GetSchema and GetSchemaAsync.
paulmedynski
paulmedynski previously approved these changes Jul 10, 2025
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski
paulmedynski requested a review from a team July 11, 2025 19:58
@paulmedynski paulmedynski self-assigned this Aug 29, 2025
This was referenced Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants