Update .NET Core Tools

Pieterjan picture Pieterjan · Oct 24, 2019 · Viewed 10.1k times · Source

I'm trying to use [email protected]. In order to do this at this point I already have: - Installed Visual Studio 2019 Preview - Installed the .NET Core 3.1 Runtime - Installed the .NET Core 3.1 SDK

Now I still can't run the command dotnet ef migrations add xxx. It's saying that I have to update the dotnet tools. So I run the following command in an administrator powershell:

PS C:\WINDOWS\system32> dotnet tool update --global dotnet-ef
Tool 'dotnet-ef' was reinstalled with the latest stable version (version '3.0.0')

Okay, not including the preview versions. So I try to specify the version explicitly:

PS C:\WINDOWS\system32> dotnet tool update --global dotnet-ef --version="3.1.0-preview1.19506.2"
error NU1202: Package dotnet-ef 3.1.0-preview1.19506.2 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any. Package dotnet-ef 3.1.0-preview1.19506.2 supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1)
Tool 'dotnet-ef' failed to update due to the following:
The tool package could not be restored.
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 Core 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

Now it's saying that a .NET Core 3.1 tool is not compatible with the .NET Core 3.1 runtime.

However, if I do a simple version check:

PS C:\WINDOWS\system32> dotnet --version
3.1.100-preview1-014459
PS C:\WINDOWS\system32> dotnet ef --version
Entity Framework Core .NET Command-line Tools
3.0.0

I can see that the EntityFrameworkCore.Tools is still at version 3.0.0 instead of 3.1.0 (which tools version is installed in my project).

Am I still missing something or is this a bug?

Answer

thinkOfaNumber picture thinkOfaNumber · Nov 19, 2019

Thanks to @lars-haupt-hansen for pointing me to the bug, I followed the trail to the PR which shows it was merged into "aspnet:release/3.1". The latest 3.1 is still a preview (preview3) [edit: it's out of preview]. You can find and download the latest SDK here.

To use it in Visual Studio projects, you have to

  1. install the SDK from the above link;
  2. go to Tools > Options > Environment > Preview Features and enable "Use previews of the .NET Core SDK"; (not required for 3.1 anymore)
  3. restart VS (not required for 3.1 anymore)
  4. Go to each project properties, and then you can choose the Target Framework .NET Core 3.1

Then to install EF Core via the command line, run dotnet tool install --global dotnet-ef from your project directory.