Repository navigation
docs: clarify required legacy SqlClient examples - #56464
dlevy-msft-sql wants to merge 4 commits into
Conversation
Add page notices and displayed sample comments only where .NET Framework integrations require System.Data.SqlClient. Preserve existing executable examples. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b0a4c59a-563b-44a5-ae83-8c4b9fe56ebc
Add page-only notices to six existing Entity Framework and LINQ to SQL integration articles. Preserve code and avoid artificial snippets. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b0a4c59a-563b-44a5-ae83-8c4b9fe56ebc
There was a problem hiding this comment.
🟢 Approval recommended
The notices explain the retained-provider constraints accurately, and the documentation and comment-only changes introduce no blocking issues.
No open issues 🎉
What changed in this PR
Clarifies why legacy .NET Framework examples retain System.Data.SqlClient, while directing new development to Microsoft.Data.SqlClient. Provider migrations remain separate.
Changes:
- Add notices and metadata updates to six articles.
- Add prohibition and dependency comments inside displayed C#, Visual Basic, and XML examples.
- Preserve executable code, snippet references, and project configuration.
| File | Description |
|---|---|
samples/snippets/visualbasic/VS_Snippets_Data/DP L2E Conceptual Examples/VB/Module1.vb |
Add Entity Framework dependency comments. |
samples/snippets/visualbasic/VS_Snippets_Data/DLinqDebuggingSupport/vb/Module1.vb |
Warn in the command-display example. |
samples/snippets/visualbasic/VS_Snippets_Data/DLinqCommunicatingWithDatabase/vb/Module1.vb |
Add LINQ to SQL connection warnings. |
samples/snippets/visualbasic/VS_Snippets_Data/DLinqAdoNet/vb/Module1.vb |
Add interoperability example warnings. |
samples/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlClient.CAS/VB/source.vb |
Explain the security example’s provider requirement. |
samples/snippets/csharp/VS_Snippets_Data/DP L2E Conceptual Examples/CS/Program.cs |
Add Entity Framework dependency comments. |
samples/snippets/csharp/VS_Snippets_Data/DLinqDebuggingSupport/cs/Program.cs |
Warn in the command-display example. |
samples/snippets/csharp/VS_Snippets_Data/DLinqCommunicatingWithDatabase/cs/Program.cs |
Add LINQ to SQL connection warnings. |
samples/snippets/csharp/VS_Snippets_Data/DLinqAdoNet/cs/Program.cs |
Add interoperability example warnings. |
samples/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlClient.CAS/CS/source.cs |
Explain the security example’s provider requirement. |
docs/framework/data/adonet/sql/linq/how-to-reuse-a-connection-between-an-ado-net-command-and-a-datacontext.md |
Explain shared-connection provider constraints. |
docs/framework/data/adonet/sql/linq/how-to-display-linq-to-sql-commands.md |
Add the retained-provider notice. |
docs/framework/data/adonet/sql/linq/how-to-connect-to-a-database.md |
Clarify LINQ to SQL migration constraints. |
docs/framework/data/adonet/sql/linq/ado-net-and-linq-to-sql.md |
Explain the interoperability provider requirement. |
docs/framework/data/adonet/ef/language-reference/known-issues-and-considerations-in-linq-to-entities.md |
Explain the Entity Framework migration boundary. |
docs/framework/data/adonet/code-access-security.md |
Add the Framework-only notice and XML comment. |
Review effort: Balanced
Restore portable net40 reference assemblies for the legacy VB sample and use the resolved Visual Basic runtime without changing its target framework or sample code. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b0a4c59a-563b-44a5-ae83-8c4b9fe56ebc
|
Final publication checks for head
The coordinating session's source review, ten original local builds, isolated-cache Debug/Release checks, and database-free Windows LINQ probe remain attributed to that session in the description. My local checks include exact patch/export comparison, complete diff review, whitespace checks, 12-article Markdown lint, and the corrected VB project's plain SDK10 build without reference-path overrides. No new SQL, Linux, or macOS runtime coverage is claimed. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b0a4c59a-563b-44a5-ae83-8c4b9fe56ebc
Summary
Coverage limits
The retained examples require Windows-only .NET Framework CAS, LINQ to SQL, or built-in
System.Data.Entity. Linux and macOS hosts are available, but they aren't supported runtimes for these unchanged integrations. The VBUInt32example fails during translation before its SQL query runs. The original net40 assembly's database method passed separately; its interactiveMaindid not complete unattended. Historical SQL Server 2000/2005 behavior wasn't reproduced on SQL Server 2025.Problem
Retained
System.Data.SqlClientexamples and integration guidance need an explicit prohibition on new development. This follow-up applies only where the existing .NET Framework integration requires that provider. It does not add warnings to examples migrated toMicrosoft.Data.SqlClient.Integration constraints
System.Data.SqlClient. Changing the connection type alone doesn't migrate LINQ to SQL.System.Data.EntitySQL provider and models whose EDMX files selectSystem.Data.SqlClient. That integration requires migration beyond a namespace substitution. The same constraint applies to the retained provider, permission, and EdmGen guidance.Solution
Add IMPORTANT boxes to 12 existing pages and prohibition/reason comments inside 31 displayed C#/VB code regions, covering 33 snippet-consumer occurrences. The inline CAS XML permission-set example receives a separate comment and is not included in those counts. Six pages receive page-only notices for existing integration guidance without displayed SDS code; no code is invented to satisfy the comment requirement. Two LINQ articles are shared-snippet consumers.
Preserve 27 executable regions unchanged and repair four LINQ regions after live validation exposed defects: missing mapped primary keys in the C#/VB parameter examples, malformed VB parameter arguments, missing whitespace in the VB joined query, and a VB DataContext created on a different connection from its transaction. Keep SDS integration, sample models, snippet identifiers, references, and C#/VB coverage. No samples are removed. After the initial snippets CI failed with MSB3644, add a project-local reference-assembly dependency and resolved Visual Basic runtime selection to the original VB Entity Framework project. Keep its .NET Framework 4.0 target unchanged. The final scope is 23 paths: 12 articles, ten source files, and one project.
Generated material includes the notices, comments, metadata, project-only build correction, and the targeted live-validation repairs. The two affected articles explain the mapped primary-key requirement and the measured C#/VB unsigned-query difference. The C# Entity Framework executable expression is unchanged; only its false expected-exception comment is corrected. These changes require normal maintainer review.
Changes
Review order: read the three executable LINQ source changes (
DLinqAdoNetin C#/VB andDLinqCommunicatingWithDatabasein VB) and theirado-net-and-linq-to-sql.mdexplanation first. Then read the EF known-issues paragraph and its comment-only C# correction, the CAS/provider-boundary notices, and the net40 project fix. Review the remaining comment-only files for wording and placement. Small follow-on changes still need review.docs/framework/data/adonet/code-access-security.mddocs/framework/data/adonet/ef/language-reference/known-issues-and-considerations-in-linq-to-entities.mddocs/framework/data/adonet/sql/linq/how-to-connect-to-a-database.mddocs/framework/data/adonet/sql/linq/how-to-display-linq-to-sql-commands.mddocs/framework/data/adonet/sql/linq/how-to-reuse-a-connection-between-an-ado-net-command-and-a-datacontext.mddocs/framework/data/adonet/sql/linq/ado-net-and-linq-to-sql.mddocs/framework/data/adonet/ef/edm-generator-edmgen-exe.mddocs/framework/data/adonet/ef/entityclient-provider-for-the-entity-framework.mddocs/framework/data/adonet/ef/security-considerations.mddocs/framework/data/adonet/ef/sqlclient-for-the-entity-framework.mddocs/framework/data/adonet/sql/linq/security-in-linq-to-sql.mddocs/framework/data/adonet/sql/linq/troubleshooting.mdsamples/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlClient.CAS/CS/source.cssamples/snippets/csharp/VS_Snippets_Data/DLinqCommunicatingWithDatabase/cs/Program.cssamples/snippets/csharp/VS_Snippets_Data/DLinqDebuggingSupport/cs/Program.cssamples/snippets/csharp/VS_Snippets_Data/DLinqAdoNet/cs/Program.cssamples/snippets/csharp/VS_Snippets_Data/DP L2E Conceptual Examples/CS/Program.cssamples/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlClient.CAS/VB/source.vbsamples/snippets/visualbasic/VS_Snippets_Data/DLinqCommunicatingWithDatabase/vb/Module1.vbsamples/snippets/visualbasic/VS_Snippets_Data/DLinqDebuggingSupport/vb/Module1.vbsamples/snippets/visualbasic/VS_Snippets_Data/DLinqAdoNet/vb/Module1.vbsamples/snippets/visualbasic/VS_Snippets_Data/DP L2E Conceptual Examples/VB/Module1.vbsamples/snippets/visualbasic/VS_Snippets_Data/DP L2E Conceptual Examples/VB/l2e_conceptualexamplesvb.vbprojValidation
At the original publication stage, this publishing session independently ran:
git apply --check <retained-sds-warnings.patch>before the initial commit: passed. Initial 16-file patch SHA256:944da698d84fcc63e3245d35797d11aada0f1a3c45e105a427261e2a30597e28.git apply --check <retained-sds-page-notices-delta.patch>before the additional six-page commit: passed. Delta SHA256:3030e5bcdc8062e7528405a9b582dad31513f4831018ad039e1f7b2647b7ceb3.git apply --check <retained-sds-ci-reference-pack.patch>before the project-only correction: passed. Delta SHA256:0d49da3ae436eeff90c0fe452d9a1d14781762db8b3f4b3b9a26404bc72f37b4.git diff 7a5a9cf8549d2356a135e1686949f4f205cc4843 --name-onlyand UTF-8/LF-normalized SHA256 hashes against the final coordinating-session export: exactly 23 paths, all 23 hashes match. The preceding 22-file documentation/source export had SHA2567dd65c2b1bd4bf8d7f9b17ff3627e57d89815344f38af819eca3df34ad6134c9; the project correction was applied as a separate delta.git diff --checkandgit diff --cached --check: passed for all three commits.npx --no-install markdownlint-cli2 docs/framework/data/adonet/code-access-security.md docs/framework/data/adonet/ef/language-reference/known-issues-and-considerations-in-linq-to-entities.md docs/framework/data/adonet/sql/linq/how-to-connect-to-a-database.md docs/framework/data/adonet/sql/linq/how-to-display-linq-to-sql-commands.md docs/framework/data/adonet/sql/linq/how-to-reuse-a-connection-between-an-ado-net-command-and-a-datacontext.md docs/framework/data/adonet/sql/linq/ado-net-and-linq-to-sql.md docs/framework/data/adonet/ef/edm-generator-edmgen-exe.md docs/framework/data/adonet/ef/entityclient-provider-for-the-entity-framework.md docs/framework/data/adonet/ef/security-considerations.md docs/framework/data/adonet/ef/sqlclient-for-the-entity-framework.md docs/framework/data/adonet/sql/linq/security-in-linq-to-sql.md docs/framework/data/adonet/sql/linq/troubleshooting.md: passed, 12 files, zero issues.git fetch origin mainconfirmed the intended base at7a5a9cf8549d2356a135e1686949f4f205cc4843; the branch contains only this independent follow-up, the six-page scope correction, and the project-only CI correction.10.0.402,dotnet build "samples\snippets\visualbasic\VS_Snippets_Data\DP L2E Conceptual Examples\VB\l2e_conceptualexamplesvb.vbproj" --nologo --verbosity quiet -warnaserror:NU1901,NU1902,NU1903,NU1904 -p:RestoreSources=https://packagefeedproxy.microsoft.io/nuget/v3/index.json: passed after the persistent project correction, without reference-path overrides. Zero errors; only existing BC42037 and BC42105 warnings.The following historical evidence predates the live-correction work and comes from the coordinating session, not new builds or runtime execution by this publishing session:
10.0.402: all ten existing sample projects built. For each project below, the coordinating session randotnet build "<project>" --nologo --verbosity quiet -warnaserror:NU1901,NU1902,NU1903,NU1904 -p:RestoreSources=https://packagefeedproxy.microsoft.io/nuget/v3/index.json.samples\snippets\csharp\VS_Snippets_ADO.NET\DataWorks SqlClient.CAS\CS\Project.csprojsamples\snippets\csharp\VS_Snippets_Data\DLinqCommunicatingWithDatabase\cs\CommWithDatabase.csprojsamples\snippets\csharp\VS_Snippets_Data\DLinqDebuggingSupport\cs\debuggingsupport.csprojsamples\snippets\csharp\VS_Snippets_Data\DLinqAdoNet\cs\cs-adonet.csprojsamples\snippets\csharp\VS_Snippets_Data\DP L2E Conceptual Examples\CS\l2e_conceptualexamplescs.csprojsamples\snippets\visualbasic\VS_Snippets_ADO.NET\DataWorks SqlClient.CAS\VB\Project.vbprojsamples\snippets\visualbasic\VS_Snippets_Data\DLinqCommunicatingWithDatabase\vb\CommWithDatabase.vbprojsamples\snippets\visualbasic\VS_Snippets_Data\DLinqDebuggingSupport\vb\debuggingsupport.vbprojsamples\snippets\visualbasic\VS_Snippets_Data\DLinqAdoNet\vb\vb-adonet.vbprojsamples\snippets\visualbasic\VS_Snippets_Data\DP L2E Conceptual Examples\VB\l2e_conceptualexamplesvb.vbprojFor the last project, the coordinating session initially restored
Microsoft.NETFramework.ReferenceAssemblies.net40version1.0.3in scratch and repeated the build withTargetFrameworkRootPath=$env:USERPROFILE\.nuget\packages\microsoft.netframework.referenceassemblies.net40\1.0.3\buildandFrameworkPathOverride=$env:USERPROFILE\.nuget\packages\microsoft.netframework.referenceassemblies.net40\1.0.3\build\.NETFramework\v4.0. That initial retry passed with zero errors and two existing VB warnings, BC42037 and BC42105. However, the scratch override did not persist to CI: the initial remotesnippets-buildfailed with MSB3644 on SDK11.0.100-rc.2.26504.105.The project-only correction adds
Microsoft.NETFramework.ReferenceAssembliesversion1.0.3withPrivateAssets="all"and the standardMicrosoft.Common.propsimport. The legacy project also needs an explicitMicrosoft.VisualBasicreference and a target beforeCoreCompilethat selects the resolved reference asVBRuntime. The coordinating session then ran a plain build without reference-path overrides, forced restore into a new isolated NuGet cache, and non-incremental Debug and Release builds on SDK10.0.402: all passed, with only existing BC42037 and BC42105 warnings. Package-audit warnings NU1901-NU1904 were treated as errors. Its evidence is retained inretained-sds-portable-build.log. SDK11 was not installed locally; actual remote snippets CI must confirm that environment. Existing analyzer/legacy warnings remain.The coordinating session also ran
powershell.exe -NoProfile -File <probe-retained-linq.ps1>on Windows10.0.26300.0, PowerShell5.1.26100.9711, CLR4.0.30319.42000.DataContext.ConnectionreturnedSystem.Data.SqlClient.SqlConnectionwith stateClosed, without attempting a SQL connection.At original publication head
52613a7d4fd74b8c9189c29df9796f7d02f01eef, runtime coverage was unchanged: no new SQL execution, Linux execution, or macOS execution for the then-comment-only source changes. Builds do not claim database behavior coverage. Original build logs, the initial missing-pack failure, successful retry, source evidence, and content manifests are retained in the coordinating session's artifacts.User-directed live SQL coverage
The original gate was pending; the earlier builds and database-free provider probe did not satisfy it. This publishing session subsequently inventoried and invoked all 31 published C#/VB regions, mapped all 33 consumer occurrences, and separately exercised the CAS permission XML and original net40 database method against
10.0.0.6:1433/test1. This is current-operation coverage with the limits near Summary, not a claim that every region issued successful SQL or that historical bugs were reproduced.Own client environment: Windows 11 Enterprise build 26300 on ARM64, .NET Framework CLR
4.0.30319.42000, PowerShell5.1.26100.9711, built-inSystem.Data.SqlClientfromSystem.Data, Version=4.0.0.0, file version4.8.10001.0. The original net40 x86 assembly ran in a compiled 32-bit CLR4 host. Actual server identity was recorded for every run: SQL Server 2025,Enterprise Edition: Core-based Licensing (64-bit),EngineEdition=3, product version17.0.5015.4. Each run used a fresh TCP probe and 45-second login timeout.1, C# and VB1,2,5, C# and VB4, C# and VB3, C# and VB1, C# and VB2, C# and VB3,4, C# and VBSBUDT543840, C# and VBUIntAsQueryParam, C# and VBSBUDT555877, C# and VBProjToAnonType1,ProjToAnonType2, C# and VBSBUDT544355, VBSeparate permission XML run: the original permission class/restrictions, with only the connection literal substituted in memory, allowed a live Open and denied a different ApplicationName. Original net40 project evidence is separate: its exact x86 assembly's
JoinOnNullreturned OrderID48000; copied/original assembly SHA256 was5052fa1c8badcc217d3c9e3c2dcd2f389a5e9c15c46ae9a25ea69ebd5de8e7df. The earlier full executable exceeded its unattended bound. The 32-bit PowerShell file host was policy-blocked; the successful compiled x86 host changed no execution policy. No completed interactive Main claim is made.Separate read-only expression observers recorded the exact shown C#/VB predicates, mapped SalesOrderID
Int32, andSystem.Data.Objects.ELinq.ObjectQueryProviderfromSystem.Data.Entity, Version=4.0.0.0. Both comparisons had Int64 operands; C# used Convert nodes, VB ConvertChecked. Observer insertions reverse exactly and are distinct from final original-region executions. The article reports these measured examples without asserting general C# UInt32 support or an unobserved ArgumentException.Validation copies substituted only authorized connection/fixture identifiers, plus explicitly recorded wrapper setup/assertions and separate observer instrumentation. Unique minimal Northwind/AdventureWorks fixtures replaced production sample databases. Every connection/fixture substitution and model-schema change reverses mechanically; C#/VB EDMX sections match structurally and extracted metadata reverses exactly. No published models changed. Nine inline blocks have explicit XML, expected-output, or command-synopsis dispositions. Every batch dropped its eight unique tables and schema; control connections/pools were closed and temporary credential configuration removed. No server settings or permissions changed.
Own commands/results for the correction:
powershell.exe -NoProfile -Command "& '<session-artifacts>\run-live-retained.ps1' -Cases @('case09','case10','case19','case24','case25') -IncludeNet40": all five corrected/join query checks passed; net40 method passed on the subsequent compiled-host retry.powershell.exe -NoProfile -Command "& '<session-artifacts>\run-live-retained.ps1' -Cases @('case04','case19','case31') -RejectProductUpdate -MakeFlagTrue": both rollback assertions passed and VB reproduced its expected SQL overflow.powershell.exe -NoProfile -Command "& '<session-artifacts>\run-live-retained.ps1' -Cases @('case12','case27')": both final original unsigned examples matched their corrected documented outcomes.dotnet build "<project>" --nologo -v:q -warnaserror:NU1901,NU1902,NU1903,NU1904 -p:RestoreSources=https://packagefeedproxy.microsoft.io/nuget/v3/index.json: passed for the four original projects containing the source/comment corrections: C# AdoNet, VB AdoNet, VB CommunicatingWithDatabase, and C# EF, at the exact paths in the historical project table. All 31 extracted-region harnesses and the unchanged net40 project also built on SDK 10.0.402. Initial--no-restorereference-import failures passed after ordinary restore; no repository dependency changes were needed.npx --no-install markdownlint-cli2 -with exact file bytes on stdin, once per article: all 12 actual article inputs passed.git diff --check: passed. Final source/region/model hashes and reversal proofs passed.Frozen local evidence:
retained-live-corrections.patchSHA256bec5ac20a944fd9240ea9e7f1b408a241b91817dd5691269c4ae05f8f85de65c; export SHA256b83e095e6bfd5db8d16294c66e207fc05563a398dc548afbab4711005e965e1b;retained-live-sql-ledger.jsonSHA256394ef30e4424c9a448df6e85c19674194c7aac195b14ea91caf7d5a15cbdc075. These are this publishing session's runs; earlier coordinating-session evidence remains historical and separately attributed.Correction-head publication checks
Published correction head:
f93168885feb97966fe491827365983edf85e0cd, one normal six-path commit with required trailers. All 23 live PR paths and committed UTF-8/LF-normalized hashes match the frozen ledger; worktree clean. No publication change altered validated source, so no additional SQL run was needed.gh run view 39482782259 --repo dotnet/docs --log: inspected the fresh successful snippets job. All ten original projects built on SDK11.0.100-rc.2.26504.105, including the persistent net40 reference-pack fix. Compiler/analyzer warning messages match the preceding published head; no new warning message was introduced.Downloaded and read the completed OpenPublishing.Build HTML linked below, and verified its Git Commit is the correction head: 23 validated paths succeeded, 12 content pages published, zero errors, zero warnings, ten suggestions. All ten suggestions are outside these 23 paths and match the previous report after timestamps are excluded. No introduced publishing finding required an edit. Markdownlint, dependency review, base-branch, build-verifier, policy, and publishing checks also passed; auto-merge was skipped and the PR remains draft. Earlier reports and build logs remain separate historical evidence.
Related context
Independent follow-up to the approved retained-provider warning requirement. Existing MDS migration drafts remain separate and unchanged: #56458, #56459, #56460, #56461, #56462, and #56463. This PR does not import their migration changes.
No issue is closed by this PR.
Internal previews
Toggle expand/collapse
Build report