dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.06k forks source link

Installing dotnet EF Core Tools for ASP.NET Application #18522

Open saimachi opened 3 years ago

saimachi commented 3 years ago

Hello,

Currently, I am working on a .NET 5 ASP.NET API application that leverages EF Core and Sqlite.

I need to install the dotnet-ef tool to create migrations, as I have updated the DbContext class in my project. However, I receive the following issue when trying to install this tool (both in the Visual Studio Package Manager console and a separate PowerShell window):

error NU1202: Package dotnet-ef 5.0.7 is not compatible with net50 (.NETFramework,Version=v5.0) / any. Package dotnet-ef 5.0.7 supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any
dotnet : The tool package could not be restored.
At line:1 char:1
+ dotnet tool install -g dotnet-ef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (The tool package could not be restored.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Tool 'dotnet-ef' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

I have tried multiple debugging steps, such as clearing the NuGet cache and updating Visual Studio 2019 (from 16.8.5 to 16.10.2).

Interestingly, I was able to install the dotnet-ef tool on my laptop with the same project.

Please suggest debugging steps. My machine uses Windows 10 Pro 20H2.

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

saimachi commented 3 years ago

As an update, I tried changing the solution to .NET Core 3.1, like the package install requested. I verified that there were no issues with NuGet dependencies, and I rebuilt the solution.

I tried installing the dotnet-ef tool again, this time locally (I made sure to create a local package manifest first). Unfortunately, I still see this error (while installing version 5.0.7 of the dotnet-ef packge).

wli3 commented 3 years ago

Could you try to install an older version of dotnet ef core that targets netcoreapp3.1?