Alternative to System.Data.SqlClient.SqlConnection class in .Net standard 2.0

Viewed 1427

I am converting a .Net core 2.1 project to .Net standard project. In .Net core 2.1 project, there was a Nuget package : System.Data.SqlClient (Contains class SqlConnection). This Nuget package and so class SqlConnection is not available in .Net Standard.

Is there any alternative to use SqlConnection in .Net standard?

3 Answers

This Nuget package and so class SqlConnection is not available in .Net Standard

Yes, it is; expand Dependencies here, and you should see that it includes targets for .NET Standard 1.2, .NET Standard 1.3, and .NET Standard 2.0; in your case, the latter should be selected automatically.

There is also the related-but-different Microsoft.Data.SqlClient package, here, which has targets for .NET Standard 2.0 and .NET Standard 2.1

That said: honestly, you're probably better off avoiding .NET Standard at this point, and just move to a recent .NET Core (or later) version, ideally .NET 5.

Yes, there is a version for System.Data.SqlClient

Maybe you need to try work with Entity Framework to get the reference or in any case you can work with ADO.NET but there is a reference.

I installed System.Data.Client through command line. It surprisingly installed. May be there was some issue with nuget.

Related