'Visual Studio Code - error NU1101: Unable to find package Microsoft.EntityFrameworkCore

I am using Visual Studio Code (VS Code) Editor for ASP.NET Core-5 Web API.

I have installed different packages in the VS Code without any error.

However, when I did:

dotnet run

I got this errors:

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.Design. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.SqlServer. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.Tools. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

How do I resolve this?



Solution 1:[1]

Your best option is to create a Nuget.config file at the root of your solution and place the following content inside:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
      <clear /> <!-- (optional) this is for clear sources like default Offline repo -->
      <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1