出于某种原因 EntityFramework 核心根本不存在

For some reason EntityFramework Core just does not exist anywhere

我不知道为什么,但是 EntityFramework 核心对我来说已经完全消失了。 它已从 Microsoft 命名空间中消失,并且在 NuGet 包浏览器甚至 dotnet CLI 直接安装中都不存在。

我尝试完全卸载并重新安装 visual studio 和所有相关工具。我试过重新加载项目。我试过直接将它注入到 csproj 文件中:

<ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>

即使我直接复制并通过此处找到的 dotnet CLI 命令 (https://www.nuget.org/packages/Microsoft.EntityFrameworkCore),它也不存在。

网络:

PS C:\Users\nikkolas\Documents\Nikkolas Diehl\Work\TestAPI> dotnet add package Microsoft.EntityFrameworkCore --version 5.0.6
  Determining projects to restore...
  Writing C:\Users\nikkolas\AppData\Local\Temp\tmp9036.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore' into project 'C:\Users\nikkolas\Documents\Nikkolas Diehl\Work\TestAPI\TestAPI.csproj'.
info : Restoring packages for C:\Users\nikkolas\Documents\Nikkolas Diehl\Work\TestAPI\TestAPI.csproj...
error: NU1101: Unable to find package Microsoft.EntityFrameworkCore. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: NU1101: Unable to find package Microsoft.EntityFrameworkCore.Design. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: NU1101: Unable to find package Microsoft.EntityFrameworkCore.SqlServer. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: NU1101: Unable to find package Microsoft.EntityFrameworkCore.Tools. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Package 'Microsoft.EntityFrameworkCore' is incompatible with 'all' frameworks in project 'C:\Users\nikkolas\Documents\Nikkolas Diehl\Work\TestAPI\TestAPI.csproj'.

下午:

Install-Package : Failed to retrieve information about 'Microsoft.EntityFrameworkCore.SqlServer' from remote source 'https://www.nuget.org/FindPackagesById()?id='Microsoft.EntityFrameworkCore.SqlServer'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 404 (Not Found).
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore -Version 5.0.6
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Time Elapsed: 00:00:03.0365187

好的,所以我找到了答案。 结果是我安装的 Visual Studio 没有正确设置 NuGet 的包源控件。 所以我不得不用正确的来源手动 link 它: https://api.nuget.org/v3/index.json