saad bin sami
saad bin sami

Reputation: 454

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

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?

Upvotes: 2

Views: 5738

Answers (3)

saad bin sami
saad bin sami

Reputation: 454

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

Upvotes: 0

Marc Gravell
Marc Gravell

Reputation: 1063338

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.

Upvotes: 3

Leandro Bardelli
Leandro Bardelli

Reputation: 11588

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.

Upvotes: 0

Related Questions