Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No executable found matching command "dotnet-ef" #5392

Closed
rowanmiller opened this issue May 17, 2016 · 31 comments
Closed

No executable found matching command "dotnet-ef" #5392

rowanmiller opened this issue May 17, 2016 · 31 comments

Comments

@rowanmiller
Copy link
Contributor

Originally reported on comments section of another issue by @christianrondeau


I could not find any solution or reference to a solution in #3925 - I am using

When I run (in the Package Manager Console)

> dotnet ef
�[1m�[31mNo executable found matching command "dotnet-ef"�[39m�[22m

Here's the dotnet version:

> dotnet --version
1.0.0-preview1-002702

Here's the project.json pieces that relate to EF:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final"
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-*",
      "imports": "portable-net452+win81"
    },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net452+win81"
      ]
    }
  },

I have installed Microsoft .NET Core 1.0.0 RC2 - VS 2015 Tooling Preview 1 and Microsoft .NET Core 1.0.0 RC2 - SDK Preview 1 (x64), I have fully uninstalled RC1 before and dotnet restore works... I'm out of ideas.

@flagbug
Copy link

flagbug commented May 17, 2016

I'm seeing this too. Note that running dotnet ef via Powershell works fine, it's only in the VS Package Manager Console that it's not working.

@smitpatel
Copy link
Contributor

smitpatel commented May 17, 2016

I hit the same error. Then I changed the current directory to the one where project.json was present and it works.
By default, VS PMC is at the root folder of solution and not the project. That would be the reason why it doesn't work for that particular case.

@rowanmiller
Copy link
Contributor Author

Ah, I missed that. You are using dotnet ef in Package Manager Console? That's not really an intended thing to do since we have proper PowerShell commands that have much richer context on the project etc. than the command line tool. You would typically use Add-Migration, Update-Database, Scaffold-DbContext etc. from Package Manager Console.

@natemcmaster
Copy link
Contributor

Too bad dotnet/NuGet don't support "global commands" yet (NuGet/Home#1605). DotNet CLI can only resolve "dotnet-ef" when it is within the project directory. This is something EF can't do anything about.

@christianrondeau
Copy link

Thanks @rowanmiller, I confirm that I indeed can run dotnet ef when outside of the Package Manager Console. I understand that you can't even display a helpful error message, since your code doesn't even get called. dotnet however still responds in the Package Manager Console, so maybe something can be done there to either give a helpful message or make it work there too? It's a very convenient place to run project-related commands :)

@natemcmaster
Copy link
Contributor

you can't even display a helpful error message, since your code doesn't even get called.

@christianrondeau bingo. We'd need changes to dotnet, NuGet, or VS to make this easier to use. Potential feature requests that may help: https://github.com/dotnet/cli/issues/917, https://github.com/dotnet/cli/issues/2939, NuGet/Home#1605

@rowanmiller
Copy link
Contributor Author

so maybe something can be done there to either give a helpful message or make it work there too? It's a very convenient place to run project-related commands :)

It should work if you cd into the project directory within Package Manager Console. The error is because PMC is at the solution directory by default. Though you will hit a rough edge where PMC will report an error even though the command executes correctly.

If you have PMC, is there a reason you would use dotnet ef over the PowerShell commands?

@rowanmiller
Copy link
Contributor Author

Closing as there isn't really anything we can do here. dotnet commands need to be invoked in the directory for the project that the command is registered in. Happy to keep discussing on this thread though.

@christianrondeau
Copy link

@natemcmaster thanks for the issue links!

@rowanmiller the reason I'm using "dotnet ef" instead of PowerShell commands in PMC is simply because I don't know better yet :P I'm following guides and tutorials to learn ASP.Net Core and EF7 together, so since I usually ran FluentMigrator in PMC, and dotnet worked there, I assumed dotnet ef would too.

@christianrondeau
Copy link

Oh and I confirm it does work when entering the project directory. I think it didn't work before (same error message) because I was missing the EF tools package.

@xperiandri
Copy link

xperiandri commented May 20, 2016

But Default project is set to right one.
Who does not use that to provide a path? dotnet? PMC? ef?

@rowanmiller
Copy link
Contributor Author

But Default project is set to right one. Who does not use that to provide a path? dotnet? PMC? ef?

The PowerShell commands make use that setting - since they have access to all the extra context of PMC. I can see the logic in saying that the dropdown should control the working directory of PMC - though I can also see the logic that says the working directory is at the solution directory. If this were to change, it would be a NuGet change - https://github.com/NuGet/Home.

@bastienJS
Copy link

@rowanmiller Fine lets continue talk here:

I created a default asp.net core .NET Core project with user authentication.

When I am inside the project dir on the CMD and do:

dotnet ef migrations add init

I get the error you see in the screenshot.

How can this be?

image

@ErikEJ
Copy link
Contributor

ErikEJ commented Jul 3, 2016

@bouassaba
Copy link

bouassaba commented Jul 3, 2016

I'm trying to get this to work on Mac, I tried the same instructions but I still get "No executable found matching command "dotnet-ef", even when I'm within the directory for thre project. Any suggestions ? or maybe some extra steps are required for Mac ?

@bouassaba
Copy link

bouassaba commented Jul 3, 2016

I confirm that it works for me now, I just forgot to add in my project.json:
"tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"}

@bastienJS
Copy link

@ErikEJ Thanks with DNXCore50 it worked!

@johanskoldekrans
Copy link

I just got a problem with this today and have been scaffolding a zillion times before without a problem.

I am using "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-22299" with dotnet core version 1.1.0-alpha1-*.

The error I get is:
dotnet : No executable found matching command "dotnet-ef"

Any ideas?

@johanskoldekrans
Copy link

I ran this from the command-line to get it to work again:

Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 1.0.0-preview3-22299

It seems as the dotnet tools got corrupted for some reason that the dotnet restore couldnt resolve. I tried to clear the package cache etc before I ran the above. After I reinstalled the package dotnet crashed and after that it has begun to work again.

@benjamincburns
Copy link

benjamincburns commented Dec 11, 2016

To anyone targeting EF Core 1.1 who might be wondering why @johanskoldekrans's solution worked, be sure to read the "Upgrading to 1.1" section in the EF Core 1.1 release announcement blog post.

As of EF Core 1.1, the EF Core tools package is now Microsoft.EntityFrameworkCore.Tools.DotNet rather than Microsoft.EntityFrameworkCore.Tools. You'll also want to be using version 1.1.0-preview4.

@aphex-
Copy link

aphex- commented Dec 14, 2016

Changing the package name to Microsoft.EntityFrameworkCore.Tools.DotNet as @benjamincburns mentioned finally did the trick. Thank you!

@mrexclamation
Copy link

@benjamincburns LIFE SAVER THANKS MAN !

@kingstonrichard
Copy link

@benjamincburns Nailed it! Thanks 👍

@raffaeu
Copy link

raffaeu commented Mar 13, 2017

Using Package Manager Console within Visual Studio 2017 RTM, you must first run a CD and be inside the project root folder.
After that you'll get all PS/DOS commands from dotnet ef cli

@josvlz
Copy link

josvlz commented May 13, 2017

Has anyone been able to make this work on the GA version of Visual Studio 2017 for Mac? I keep getting message Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.1' has a package type 'DotnetCliTool' that is not supported by project 'EFGetStarted.AspNetCore.NewDb'. when I try to add Microsoft.EntityFrameworkCore.Tools.DotNet, version 1.0.1.

@nayoonhwang
Copy link

@reynjoz I get the same error. It can be an error in Visual Studio for Mac. I couldn't find the way to handle database in VS for MAC.

@nayoonhwang
Copy link

@reynjoz I found the solution.
stackoverflow_link

@hkumipig
Copy link

screen shot 2018-02-19 at 4 51 56 pm
Kindly help me. I just created demo project on my MAC and error appear.

@smitpatel
Copy link
Contributor

@hkumipig - Few questions.

  • Did you run dotnet restore?
  • Is your csproj file containing DotNetCliToolReference is inside demo folder? If not then cs into folder containing the csproj.

If above does not fix the problem then share your directory structure and csproj file please.

@hkumipig
Copy link

hkumipig commented Feb 20, 2018

screen shot 2018-02-20 at 8 51 28 am

@smitpatel Thank you for your response
Yes already run the dontnet restore "Packages successfully restored."

Please see attached file, how i run the 'dotnet ef'.

netcoreapp2.0 ---------------------------------------------------------------------------------------

@smitpatel
Copy link
Contributor

Already answered to @hkumipig in a different thread.
For others, if you are using VS for Mac then you would need to run dotnet restore on command line manually. Even though VS for Mac says packages restored successfully it does not restore DotNetCliToolReference properly.
Tracking external issue https://developercommunity.visualstudio.com/content/problem/198601/vs-restore-function-not-the-same-as-cli-when-resto.html

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests