3

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 3

3

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I cant see option to add it through nuget. the package link says that it supports .net standard 2.0 but it does not show in nuget.
@saadbinsami what tool are you using here? It should work just fine. The main exception would be things like "Unity". Is this Unity?
I was using Nuget
@saad I meant as your target platform; it is absolutely available on nuget - I've shown the links, they work just fine as package refs for most conventional targets
yes package was available on my target plateform.
0

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.

Comments

0

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

1 Comment

Editing the csproj is usually the easiest way to add package references; nuget includes the XML for this on one of the tabs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.