1
votes

I created a new .Net core console project using the following command.

dotnet new console
dotnet run

However, Install-Package System.Data.SqlClient got the following error?

PS C:\temp> dotnet new console
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\temp\temp.csproj...
  Restore completed in 215.56 ms for C:\temp\temp.csproj.

Restore succeeded.

PS C:\temp> dotnet run
Hello World!
PS C:\temp> Install-Package System.Data.SqlClient
Install-Package : No match was found for the specified search criteria and package name 'System.Data.SqlClient'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package System.Data.SqlClient
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
PS C:\temp> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.701
 Commit:    8cf7278aa1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.701\

Host (useful for support):
  Version: 2.1.12
  Commit:  ccea2e606d

.NET Core SDKs installed:
  2.1.507 [C:\Program Files\dotnet\sdk]
  2.1.508 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.1.701 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
1
Shouldn't it be: dotnet add package ? docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-packageStefan
You might want to read devblogs.microsoft.com/dotnet/…ADyson

1 Answers

0
votes

Due to .NET Core framework changes System.Data.SqlClient has been decoupled from framework to enable timely and independent from .NET Core development cycle support of Microsoft SQL Server and Azure SQL. You should use OOB (out of the box) package Microsoft.Data.SqlClient when working with .NET Core 3.0 or greater.

For more details see the following blog post: Introducing the new Microsoft.Data.SqlClient