Trying to install Microsoft.Data.SqlClient fails on .NET 8.0.204

After creating a brand new console project with .NET 8.0.204

When I run:

dotnet add package Microsoft.Data.SqlClient --version 5.2.0

It fails installing the package with the following error:

Determining projects to restore...
Writing C:\Users\alamadrid\AppData\Local\Temp\tmpfoxkvh.tmp
info : X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
info : X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
info : Adding PackageReference for package 'Microsoft.Data.SqlClient' into project 'C:\Users\alamadrid\Documents\Projects\STATMiniAgentLinux\STATMiniAgentLinux.csproj'.
info : Restoring packages for C:\Users\alamadrid\Documents\Projects\STATMiniAgentLinux\STATMiniAgentLinux.csproj...

error: NU1100: Unable to resolve 'Microsoft.Data.SqlClient (>= 5.2.0)' for 'net8.0'.
error: Package 'Microsoft.Data.SqlClient' is incompatible with 'all' frameworks in project 'C:\Users\alamadrid\Documents\Projects\STATMiniAgentLinux\STATMiniAgentLinux.csproj'.

Microsoft.Data.SqlClient 5.2.0 should support .NET 8.0.204, as that's what it says on the release notes of that version.

Release Notes

Whats a little more strange is that I couldnt find anyone online having the same issue as me.

Please see below my csproj file.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

Upvotes: 0

Views: 540

Answers (2)

Alexander Vogt
Alexander Vogt

Reputation: 11

Had a similar issue where I was simply not able to install Microsoft.Data.SqlClient package.

I was able to solve it by clearing the nuget cache:

dotnet nuget locals all --clear

and then deleting my local nuget config:

del /q %AppData%\NuGet\NuGet.Config

Afterwards I was able to install the package.

Upvotes: 1

I tried the installation again in another machine and I no longer have that error. Seems like some issues with Nuget.

Upvotes: 0

Related Questions