You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Performance 📈Issues that are targeted to performance improvements.Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the label
Today we are reading in the SqlMetaData.xml file and parsing it into data structures at runtime. See if we can do that work at compile time and generate some static code or data structures instead to avoid runtime overhead and possible errors.
SqlMetaData.xml (returned via SqlConnection.GetSchema("DataTypes").)
Having a single place to add new types and to "hydrate" them with a precision/length where necessary would be convenient. In the long term, it might also help to lift some of the parsing logic out of TdsParser (although hopefully SqlClientX will pre-empt that.)
Hello,
I would like to try tackling this task using source generators, but while studying metadata handling in SqlClient I'm wondering why it is being kept in .xml file in the first place, instead of being hardcoded in C#?
It's largely historical. This is used to support output for DbConnection.GetSchema, and in .NET Framework System.Data.SqlClient made heavy use of shared underlying ADO.NET components. In this situation, it made sense for multiple ADO.NET providers to share an implementation which returned a DataTable, to have that implementation clone a "reference DataSet" and to load that reference DataSet from an embedded resource.
When the library was split out into Microsoft.Data.SqlClient, the relevant shared ADO.NET components were split with it. Since then, we've had some movement:
There's one piece of intersecting work to add the json and the vector types to the DataTypes table and fix bug #3833, but this depends upon #3862.
It's a fairly self-contained part of the codebase to start work in, but will often lead to very large PRs! There are three tables left untouched by PRs at the moment: MetaDataCollections, Restrictions and DataSourceInformation.
@edwardneal Thanks for info,
but would you still suggest to try to parse SqlMetaData.xml at compile time, or to bring remaining metadata tables : MetaDataCollections, Restrictions and DataSourceInformation inside? I have noticed, that your work on ReservedWords and DataTypes is rather recent, so wouldn't my work interfere with yours?
No problem. Unless the SqlClient team wants to use a source generator instead, I'd suggest maintaining the same approach as we currently use.
I think our work would only overlap when it touches ReservedWords, and that's a fairly recent, unmerged, PR. With that said, if there's an issue avoiding that specific table and your PR ends up landing first then I've not got a problem rebasing or closing mine.
Not applicable (engineering/refactoring task, not a bug report)
Area
Area\Engineering
Duplicates
None found as a duplicate; related/overlapping in-progress work: #3369, #3818, #3858, #4328 (partial migrations of individual SqlMetaData.xml-backed tables to code)
Regression
Not applicable
Analysis
This is a long-standing engineering task to move SqlMetaData.xml (and related runtime-parsed metadata used by SqlConnection.GetSchema) from an embedded XML resource parsed at runtime into compile-time-generated code/data, reducing runtime overhead, trimming friction, and parsing errors. Per the issue discussion, several of the constituent tables (DataTypes, ReservedWords) have already been converted incrementally in separate PRs, and three tables remain untouched (MetaDataCollections, Restrictions, DataSourceInformation). This is a Area\Engineering / performance-adjacent task, low severity (P3) since it's non-functional/internal refactoring with no user-facing bug, but valuable for maintainability and startup performance.
Next Steps
Coordinate with @edwardneal and @tetolv (active contributors in the thread) to avoid duplicate effort on the remaining tables (MetaDataCollections, Restrictions, DataSourceInformation).
Given the issue is already labeled Up-for-Grabs, this is best handled by a community contributor or, if unassigned for a while, could be assigned to Copilot coding agent to draft the conversion for one of the three remaining tables (starting with DataSourceInformation, the smallest) following the pattern established in Fix | Build DataTypes table in code, add json data type #3858.
Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.
Performance 📈Issues that are targeted to performance improvements.Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the label
Activity
edwardneal commentedon May 22, 2025
It might also be useful to account for where SqlClient stores its records of various types. At present, we've got a number of sources:
TdsEnumsMetaTypeSqlMetaDataPrivSqlConnection.GetSchema("DataTypes").)Having a single place to add new types and to "hydrate" them with a precision/length where necessary would be convenient. In the long term, it might also help to lift some of the parsing logic out of TdsParser (although hopefully SqlClientX will pre-empt that.)
tetolv commentedon Jun 2, 2026
Hello,
I would like to try tackling this task using source generators, but while studying metadata handling in SqlClient I'm wondering why it is being kept in .xml file in the first place, instead of being hardcoded in C#?
edwardneal commentedon Jun 2, 2026
It's largely historical. This is used to support output for
DbConnection.GetSchema, and in .NET Framework System.Data.SqlClient made heavy use of shared underlying ADO.NET components. In this situation, it made sense for multiple ADO.NET providers to share an implementation which returned a DataTable, to have that implementation clone a "reference DataSet" and to load that reference DataSet from an embedded resource.When the library was split out into Microsoft.Data.SqlClient, the relevant shared ADO.NET components were split with it. Since then, we've had some movement:
DataSet.ReadXmlto load the reference DataSet with a trim-friendly XML deserializerjsondata type #3858 built one of the larger tables (DataTypes) in codeThere's one piece of intersecting work to add the
jsonand thevectortypes to the DataTypes table and fix bug #3833, but this depends upon #3862.It's a fairly self-contained part of the codebase to start work in, but will often lead to very large PRs! There are three tables left untouched by PRs at the moment: MetaDataCollections, Restrictions and DataSourceInformation.
tetolv commentedon Jun 3, 2026
@edwardneal Thanks for info,
but would you still suggest to try to parse
SqlMetaData.xmlat compile time, or to bring remaining metadata tables : MetaDataCollections, Restrictions and DataSourceInformation inside? I have noticed, that your work on ReservedWords and DataTypes is rather recent, so wouldn't my work interfere with yours?edwardneal commentedon Jun 3, 2026
No problem. Unless the SqlClient team wants to use a source generator instead, I'd suggest maintaining the same approach as we currently use.
I think our work would only overlap when it touches ReservedWords, and that's a fairly recent, unmerged, PR. With that said, if there's an issue avoiding that specific table and your PR ends up landing first then I've not got a problem rebasing or closing mine.
priyankatiwari08 commentedon Sep 17, 2026
/triage
github-actions commentedon Sep 17, 2026
🔍 Triage Summary (on-demand re-triage)
Area\EngineeringSqlMetaData.xml-backed tables to code)Analysis
This is a long-standing engineering task to move
SqlMetaData.xml(and related runtime-parsed metadata used bySqlConnection.GetSchema) from an embedded XML resource parsed at runtime into compile-time-generated code/data, reducing runtime overhead, trimming friction, and parsing errors. Per the issue discussion, several of the constituent tables (DataTypes,ReservedWords) have already been converted incrementally in separate PRs, and three tables remain untouched (MetaDataCollections,Restrictions,DataSourceInformation). This is aArea\Engineering/ performance-adjacent task, low severity (P3) since it's non-functional/internal refactoring with no user-facing bug, but valuable for maintainability and startup performance.Next Steps
@edwardnealand@tetolv(active contributors in the thread) to avoid duplicate effort on the remaining tables (MetaDataCollections,Restrictions,DataSourceInformation).@tetolv) is preferred over continuing the current manual "port table to code" pattern used in Fix | Build DataTypes table in code, addjsondata type #3858/Fix | Build ReservedWords table in code #4328, since this affects how new contributions should be structured.Up-for-Grabs, this is best handled by a community contributor or, if unassigned for a while, could be assigned to Copilot coding agent to draft the conversion for one of the three remaining tables (starting withDataSourceInformation, the smallest) following the pattern established in Fix | Build DataTypes table in code, addjsondata type #3858.