visual studio – Why can’t I use Microsoft.Data.SqlClient with .NET 8?


I am trying to create a C# class library using Visual Studio 2022 Community.
The project is using Microsoft.Data.SqlClient. NuGet recommended to get version 5.8.2.

This did not work when using the DLL of the class library from a Console application C# targeting .NET 6. I was receiving an error:

Microsoft.Data.SqlClient is not supported on this platform

I then tried to lower the versions of Microsoft.Data.SqlClient to 4.0.5 and when calling this class from a Console application I receive:

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly ‘System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. The system cannot find the file specified.

Can anyone suggest what combination of Target Framework and Microsoft.Data.SqlClient can work?

Leave a Reply

Your email address will not be published. Required fields are marked *