dotnet / dotnet/SqlClient

Microsoft.Data.SqlClient is not supported on this platform with .NET9 class library and winforms app

Open
#3,006 8 comments 0 reactions 1 assignee Claimed by @cheenamalhotra View on GitHub
Dominant language
C#
Stars
989
Forks
340
Avg merge
4d 19h
Merged PRs (30d)
72

Description

### 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 (https://github.com/dotnet/SqlClient/issues/2840) or .NET Framework (https://github.com/dotnet/SqlClient/issues/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
```

### 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.