user4912134
user4912134

Reputation: 1043

Unable to install the System.Data.SqlClient

I am trying to create Web API that will connect to the SQL server and run the stored procedure. I wanted to install the System.Data.SqlClient in to the project so I can give the connection details. But when tried to install that through the Nuget Manager it throws error like

 Install failed. Rolling back...
 Could not install package 'System.Data.SqlClient 4.3.0'.
 You are trying to install this package into a project that targets. 
 '.NETFramework,Version=v4.5', but the package does not contain any 
 assembly references or content files that are compatible with that 
 framework. For more information, contact the package author.

How can I install them or is there any other way of giving the connectionStrings in web.config

Upvotes: 3

Views: 3142

Answers (1)

Sean Stayns
Sean Stayns

Reputation: 4234

I could solve this problem with a little workaround for Xamarin PCL:

  1. Change your PCL target to .NetStandard. You can do it in the PCL project properties.
  2. Create a new .NetStandard ClassLibrary project.
  3. Add the System.Data.SqlClient and your code
  4. Reference the ClassLibrary project dll to the PCL project
  5. With this library you can use the SqlClient.

In your case with asp.net: Perhaps, you can try to create a .NetFramework ClassLibrary and follow the steps above.

I hope it will help you!

Upvotes: 1

Related Questions