Microsoft.Data.SqlClient is not supported on this platform with .NET9 class library and winforms app #3006
Labels
✔️ Repro Available
Issues that are reproducible with repro provided.
✔️ Triage Done
Issues that are triaged by dev team and are in investigation.
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.
Reproduce / test repo
I created a test repo to show this problem: https://github.com/heckradr/SQL-Client-Problems
Further technical details
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)
The text was updated successfully, but these errors were encountered: