Cannot install System.Data.SqlClient from NuGet or Dotnet cli

Damian Young 0 Reputation points
2023-07-25T14:11:53.16+00:00

Hi everyone I have tried searching how and low for a response to this but to no avail.

I am trying to install System.Data.SqlClient for a backend server. When I open Visual Studio (Community Edition) and follow the regular workflow to install NuGet packages (Solution -> Manage NuGet Packages For Solution) System.Data.SqlClient is not displayed in the Browse section. When I run the command from the dotnet cli

dotnet add package System.Data.SqlClient --version 4.8.5

I get the error

C:\Users\Damian\source\repos\Doorpack2.0\Doorpack2.0.csproj(256,3): error MSB4019: The imported project "C:\Program Files (x86)\dotnet\sdk\7.0.109\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\ProgramFiles(x86)\dotnet\sdk\7.0.109\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.Unable to create dependency graph file for project 'C:\Users\Damian\source\repos\Doorpack2.0\Doorpack2.0.csproj'. Cannot add package reference.

In the Microsoft folder in the stacktrace the folder VisualStudio\v17.0 does not exist so I wonder if this is why?

If so does anyone know any resolutions for this error? If you need any further clarification please let me know I've tried to be in depth.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,573 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,396 questions
.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
326 questions
{count} votes