Update .NET Core Tools

10,141

Solution 1

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.

Solution 2

dotnet tool install -g dotnet-ef --version 3.0.0-preview4.19216.3

dotnet tool install --global dotnet-ef --version 3.0.0-preview8.19405.11
Share:
10,141

Related videos on Youtube

Pieterjan
Author by

Pieterjan

Updated on June 04, 2022

Comments

  • Pieterjan
    Pieterjan about 2 years

    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?

    • magicandre1981
      magicandre1981 over 4 years
      do you have 16.4 preview 2 installed?
    • Pieterjan
      Pieterjan over 4 years
      My version is 16.4.0 Preview 2.0
    • Pieterjan
      Pieterjan over 4 years
      I tried to install everything on a new Windows installation on another laptop and I immediately chose .NET Core 3.1, no other .NET Core frameworks. Now when I run dotnet --version I also get 3.1.100-preview1-014459 and dotnet ef --version gives me 3.1.0 as well. But now dotnet ef complains about the fact that I use .NETCore3.1 and tells that it's only compatible with .NETCore3.1. Probably a bug.
    • magicandre1981
      magicandre1981 over 4 years
      could be. report it to Microsoft
  • Yunnosch
    Yunnosch over 4 years
    I doubt that this solves the problem or even works at all. To convince me otherwise please explain how this works and why it is supposed to help.