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
{{ message }}
Repository navigation
Microsoft.Data.SqlClient is not supported on this platform with .NET9 class library and winforms app #3006
Microsoft.Data.SqlClient is not supported on this platform
On a windows 11 pc with the latest Visual Studio 2022 (17.13.0, preview 1) I get an exception "Microsoft.Data.SqlClient is not supported on this platform" when using EF Core in an DLL project which is referenced by another project (for example a winforms project).
I'm using EF-Core 9 with .NET 9 (but encountered the same problem with .NET8).
I saw other issues with this exception in combination with .NET Standard (#2840) or .NET Framework (#2786), but in my case there are only .NET8/9 projects involved.
You can solve the problem by including the Microsoft.Data.SqlClient NuGet package directly in the WinForms project. However, I see this as just a workaround; it should actually work without this direct reference.
Exception message:
Microsoft.Data.SqlClient is not supported on this platform
Microsoft.Data.SqlClient version: 5.16.24240.5 (but same problem with 5.22.24240.6)
.NET target: .NET9
SQL Server version: SQL Server 2022
Operating system: Windows 11 23H2 (22631.4460)
@cheenamalhotra did you have a chance to look into this issue? I'm still encountering the same error, even with the latest versions. Thanks in advance!
Why would you actually expect the single .dll reference to work??
Counter question: Why shouldn't it work? All the necessary DLLs are in the output directory, but the SQL client seems to have trouble recognizing which platform it's running on.
I don't want to integrate every transitive dependency into my application as a direct dependency.
If you copy C:\Users<myUser>.nuget\packages\microsoft.data.sqlclient\6.1.1\runtimes\win\lib\net9.0\Microsoft.Data.SqlClient.dll
manually to your output directory after compile it works as expected.
The files have the same name, but differ allready in size: working: 2.117KB vs. not working 909KB
If you copy C:\Users.nuget\packages\microsoft.data.sqlclient\6.1.1\runtimes\win\lib\net9.0\Microsoft.Data.SqlClient.dll manually to your output directory after compile it works as expected.
The files have the same name, but differ allready in size: working: 2.117KB vs. not working 909KB
Nevertheless this is very annoying.
In my test scenario, the file is 270 KB in both the running version and the faulty app. It's always the same file (MD5 checked). Therefore, it can't be related to the DLL itself.
All required environment details provided for investigation
Area
Area\Engineering
Duplicates
Potentially related: #2840, #2786 (referenced by reporter); a fix PR is already linked to this issue: #4673 "Remove RID-specific SqlClient DLLs"
Regression
Not indicated (issue is about RID-specific asset resolution, not a version regression)
Analysis
This is a packaging/build issue: when Microsoft.Data.SqlClient is referenced only transitively (via a class library that is itself referenced by a WinForms/EXE project), MSBuild's asset-selection logic does not correctly copy the platform-specific (RID-specific) Microsoft.Data.SqlClient.dll/Microsoft.Data.SqlClient.SNI.dll to the final executable's output directory, causing the "is not supported on this platform" PlatformNotSupportedException at runtime. Workarounds (adding an explicit direct package reference, setting RuntimeIdentifiers, or manually copying the correct DLL) confirm the root cause is asset selection/copy behavior rather than a logic bug in SqlClient itself. Severity: P2 (workaround exists, but affects any multi-project .NET 8/9 solution using transitive references, which is common). This issue already has an associated fix PR (#4673) that removes RID-specific SqlClient DLLs, which appears to directly address this class of problem.
Next Steps
Since a fix PR (Remove RID-specific SqlClient DLLs #4673 "Remove RID-specific SqlClient DLLs") is already linked as closing this issue, prioritize reviewing and merging that PR rather than assigning new investigation.
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.
Activity
cheenamalhotra commentedon Mar 25, 2025
@heckradr
Have you tried including in your
TestOutsideSolutionproject file:heckradr commentedon Mar 25, 2025
@cheenamalhotra
I added RuntimeIdentifiers to my test repository and committed the changes. However, I am still encountering the same error.
heckradr commentedon Jul 20, 2025
@cheenamalhotra did you have a chance to look into this issue? I'm still encountering the same error, even with the latest versions. Thanks in advance!
ErikEJ commentedon Jul 20, 2025
Why would you actually expect the single .dll reference to work??
heckradr commentedon Jul 20, 2025
Counter question: Why shouldn't it work? All the necessary DLLs are in the output directory, but the SQL client seems to have trouble recognizing which platform it's running on.
I don't want to integrate every transitive dependency into my application as a direct dependency.
bauradar commentedon Aug 16, 2025
If you copy C:\Users<myUser>.nuget\packages\microsoft.data.sqlclient\6.1.1\runtimes\win\lib\net9.0\Microsoft.Data.SqlClient.dll
manually to your output directory after compile it works as expected.
The files have the same name, but differ allready in size: working: 2.117KB vs. not working 909KB
Nevertheless this is very annoying.
heckradr commentedon Aug 24, 2025
In my test scenario, the file is 270 KB in both the running version and the faulty app. It's always the same file (MD5 checked). Therefore, it can't be related to the DLL itself.
bauradar commentedon Aug 25, 2025
Hi,
add also Microsoft.Data.SqlClient.SNI.dll to your outuput.
Niko
priyankatiwari08 commentedon Sep 17, 2026
/triage
github-actions commentedon Sep 17, 2026
🔍 Triage Summary (on-demand re-triage)
Area\EngineeringAnalysis
This is a packaging/build issue: when
Microsoft.Data.SqlClientis referenced only transitively (via a class library that is itself referenced by a WinForms/EXE project), MSBuild's asset-selection logic does not correctly copy the platform-specific (RID-specific)Microsoft.Data.SqlClient.dll/Microsoft.Data.SqlClient.SNI.dllto the final executable's output directory, causing the "is not supported on this platform"PlatformNotSupportedExceptionat runtime. Workarounds (adding an explicit direct package reference, settingRuntimeIdentifiers, or manually copying the correct DLL) confirm the root cause is asset selection/copy behavior rather than a logic bug in SqlClient itself. Severity: P2 (workaround exists, but affects any multi-project .NET 8/9 solution using transitive references, which is common). This issue already has an associated fix PR (#4673) that removes RID-specific SqlClient DLLs, which appears to directly address this class of problem.Next Steps
Microsoft.Data.SqlClientwhen consumed transitively through a class library, and verify the fix against the reporter's linked repro repo (https://github.com/heckradr/SQL-Client-Problems).