Azure-docs: Unable to start project - "dotnet ef database update" does not work

Created on 3 Oct 2019  Â·  21Comments  Â·  Source: MicrosoftDocs/azure-docs

When I ran the command in Git Bash, I got the following error:

$ dotnet ef database update
Could not execute because the specified command or file was not found.
Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-ef does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Therefore I can't run the project and do any more of the tutorial


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 app-service-wesvc cxp product-question triaged

Most helpful comment

I got it to work by running:
dotnet tool install --global dotnet-ef
(found this at https://stackoverflow.com/questions/55974734/ef-core-tools-not-working-on-dotnet-core-3-preview-4).

All 21 comments

@richjhart Thanks for the feedback! We are currently investigating and will update you shortly.

Similar issue. When I updated the dotnet ef tool using the instructions referenced here (https://github.com/aspnet/EntityFrameworkCore/issues/15448#issuecomment-485893936) by using the command dotnet tool install -g dotnet-ef --version 3.0.0-preview4.19216.3. the new error I receive is:
"dotnet ef database update
System.MissingMethodException: Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'."

Any help would be appreciated. Thanks!

@richjhart and @sandarvanlaan I'm assuming you're on a windows machine. Did you run the .NET Core installer for linux? See https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro#linuxubuntu

If you didn't and you're just doing the tutorial, you don't need bash, just open the command prompt instead.

I'm getting the same error. I'm on a Windows machine and running:

Install .NET Core
browse: https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro
click: Download and install
click: Download .NET SDK (64-bit) (installs Microsoft .NET Core SDK 3.0.100)
open Command Prompt
cd c:\p\repos (my working directory)
git clone https://github.com/azure-samples/dotnetcore-sqldb-tutorial
cd dotnetcore-sqldb-tutorial
dotnet restore
dotnet ef database update (get error on this line!)

What gives?

I got it to work by running:
dotnet tool install --global dotnet-ef
(found this at https://stackoverflow.com/questions/55974734/ef-core-tools-not-working-on-dotnet-core-3-preview-4).

@BryanTrach-MSFT - Yes I did run the installer at the URL you referenced. And I'm just in a cmd prompt window. The first command "dotnet restore" works fine, but the second ""dotnet ef database update" still errors out as if the cmd isn't recognized. I tried @roalexan's recommended solution, but still getting this:
"Could not execute because the specified command or file was not found.
Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-ef does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH."

Thanks!

Wow. Ok, I got it. Not sure how much help it'll be for anyone else. But I ran the full install of Visual Studio 2019. Running the command then gave me this error:
dotnet ef database update
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.2.0' was not found.

  • The following frameworks were found:
    2.1.13 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    3.0.0 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The .NET Core frameworks can be found at:

Then I ran the 2.2.7 .NET Core installer from here:
https://dotnet.microsoft.com/download/dotnet-core/2.2

Aaaaand it finally worked! Alright, thanks all.

Hi Guys,

I still have the same problem

My Env:
Win10
MSVS 2019 Community 16.3.1
with
.NET Core 2.1. LTS RUntime
.NET Core 2.2 Runtime
.NET Core 3.0 SDK

I have installed
dotnet tool install -g dotnet-ef --version 3.0.0-preview4.19216.3
(with all variations described by roalexan according https://stackoverflow.com/questions/55974734/ef-core-tools-not-working-on-dotnet-core-3-preview-4)

But still have this stopper
System.MissingMethodException: Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.

It appears either I run command line or bash
(if using bash I have "dotnet: command not found")

I can temporarily overcome this by uninstalling .NET Core 3.0 SDK (Using MSVS Installer UI -> modify -> Individual components) but it is not appropriate solution for me because this case MSVS uninstalls some important tools for .NET Core developing and I need install them again and it brings me back to have .NET Core 3.0 that again reproduces the issue.

Any solution?

@dmikos .NET Core 3.0 is now GA. Have you tried re-installing the SDK from the Visual Studio Installer? dotnet-ef is available by default.

image

I today I had the same issue with dotnet ef database update error.
I reinstalled .NET Core packages as suggested by @RyanHill-MSFT
But unfortunately it ended with the same error as @dmioks
System.MissingMethodException: Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'. at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute() at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0() at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.

edit:
What helped in my case, was manual install of specific dotnet-ef version
dotnet tool update --global dotnet-ef --version 3.0.0-preview7.19362.6
as mentioned in this case in Stack

@kstudnik Yes, this is the workaround that we were going to share as we believe it should help to resolve a majority of the issues on this thread.

Since a majority of these items seem to be troubleshooting related caused by the switch to .net core 3.0 and not by this doc specifically and we believe kstudnik's response should help, we will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.

@BryanTrach-MSFT I have a project that I am working on running Microsoft.EntityFrameworkCore 2.2.4. VS19 v16.3.7 and am unable to execute 'dotnet ef' commands from Package Manager Console. I don't want to upgrade to .NET 3.0, what is the workaround for this?

image

image

@rezamohamed same boat. let me know if you find anything.

@tiwari-abhishek I got it to work by just reinstalling the EF Core Nuget packages with the 2.2.4 version which is what my project was targeting

I just tried running this tutorial and got the same error: Could not execute because the specified command or file was not found.
Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-ef does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

I am on version 3.1.100 of dotnet core. And ran the following commands:
git clone https://github.com/azure-samples/dotnetcore-sqldb-tutorial
cd dotnetcore-sqldb-tutorial
dotnet restore
dotnet ef database update

Forgot to say this was on windows.

Facing the same issue while adding migrations, using Windows and .Net Framework 2.2

PM> dotnet ef migrations add CreateDatabase
dotnet : Could not execute because the specified command or file was not found.
At line:1 char:1

  • dotnet ef migrations add CreateDatabase
  • ~~~~~~~~~~~

    • CategoryInfo : NotSpecified: (Could not execu... was not found.:String) [], RemoteException

    • FullyQualifiedErrorId : NativeCommandError

Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-ef does not exist.
  • You intended to r
    un a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Also, Updated the dotnet version by using following commands.

PM> dotnet tool update --global dotnet-ef
You can invoke the tool using the following command: dotnet-ef
Tool 'dotnet-ef' (version '3.1.1') was successfully installed.

I got it to work by running:
dotnet tool install --global dotnet-ef
(found this at https://stackoverflow.com/questions/55974734/ef-core-tools-not-working-on-dotnet-core-3-preview-4).

This has worked for me.
Thanks @roalexan

I got it to work by running:
dotnet tool install --global dotnet-ef
(found this at https://stackoverflow.com/questions/55974734/ef-core-tools-not-working-on-dotnet-core-3-preview-4).

This worked for me as well, however I was I also had to configure my Package source, Package manager was looking at my companies package repo, and ignoring nuget.org. I had to go in and uncheck the other package sources, leaving only nuget.org.

This may help someone.

when i run dotnet tool install --global dotnet-ef I got "Response status code does not indicate success: 401 (Logon failed.)" so I checked file appdata/nuget/nuget.config
and removed this key <add key="telerik" value="https://nuget.telerik.com/nuget" /> under <packageSources>

This Worked for me
dotnet tool update --global dotnet-ef
_Tool 'dotnet-ef' was successfully updated from version '3.0.0-preview4.19216.3' to version '3.1.5'._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrdfuse picture mrdfuse  Â·  3Comments

jamesgallagher-ie picture jamesgallagher-ie  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

bityob picture bityob  Â·  3Comments

Ponant picture Ponant  Â·  3Comments