Install-Package:找不到与指定搜索条件和程序包名称'System.Data.SqlClient'

时间:2019-07-12 21:08:54

标签: c# .net-core

我使用以下命令创建了一个新的.Net核心控制台项目。

dotnet new console
dotnet run

但是,Install-Package System.Data.SqlClient遇到以下错误?

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 个答案:

答案 0 :(得分:0)

由于.NET Core框架的更改, System.Data.SqlClient 已与框架分离,以实现对Microsoft SQL Server和Azure SQL的.NET Core开发周期的及时且独立的支持。使用.NET Core 3.0或更高版本时,应使用OOB(即用型)软件包 Microsoft.Data.SqlClient

有关更多详细信息,请参见以下博客文章:Introducing the new Microsoft.Data.SqlClient