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

dotnet ef does not work after running dotnet tool install -g dotnet-ef #15448

Closed
natemcmaster opened this issue Apr 22, 2019 · 26 comments
Closed
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. customer-reported

Comments

@natemcmaster
Copy link
Contributor

Filing on behalf of @DamianEdwards

Describe what is not working as expected.

image

Error message: The application to execute does not exist

Steps to reproduce

With a .NET Core 3.0 SDK, run dotnet tool install -g dotnet-ef and run dotnet ef

@shawty
Copy link

shawty commented Apr 23, 2019

Just hit by exactly the same scenario here:

image

After installing the tools using the same command line.

I was working through this tutorial : https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite

Just to make sure my tooling was working in the latest V3 sdk preview

image

Cheers
Shawty

@natemcmaster
Copy link
Contributor Author

The workaround for .NET Core 3.0 SDK users is to run

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

@shawty
Copy link

shawty commented Apr 23, 2019

@natemcmaster Awesome thanks. :-)

I'm was under the impression it was something to do with the builds still being in preview, so I assume this will just automatically fix itself once DNC3 goes prod.

@ajcvickers
Copy link
Member

The behavior on 3.0 is expected because install doesn't look at preview packages, and hence tries to load the 2.2 package, which is not intended to be loaded in this way. This means that:

  • We don't need to fix this for 3.0. Indeed, this could be seen as a workaround for a limitation in global tools, which is something I have been asked explicitly not to do.
  • If we need it for 2.2, where is the customer impact? I.e. How does it meet the bar for servicing?

We will discuss this in triage, but for now this feels like a won't fix to me.

@shawty
Copy link

shawty commented Apr 24, 2019

I agree to be fair. I don't expect a fix per say, but what might be an idea is to borrow from the NuGet screen in VS, where there is a tick box that says "consider previews", and implement something like that, either via a command line option, or an environment variable.

The only reason I suggest this, is because folks like me don't always/or are not always privy to the actual versions we need for a given core tooling version.

In my case above, I defaulted to the * in my install simply because I didn't expect any different, once it was pointed out I needed a specific version, and the version was given it was obvious, and the penny dropped.

There are however many developers now converting to use Core, that don't have the benefit of experience, and so will blindly type in any command line version combo there told too, thus making more work for the support teams when things inevitably go wrong for them.

Having a "tick" that can be enabled (Disabled by default) that allows the command to stop, look at it's actual version and see if there is a preview that matches it, would them mean support is as easy as

"add the -foo parameter to your command line"

Just my thoughts on things, not really expecting any note to be taken of them :-)

Shawty

@AhmedHemdan21
Copy link

AhmedHemdan21 commented May 9, 2019

I had the same issue with .NET Core 2.2 after i have installed .NET Core 3.0 Preview

when i try to execute

dotnet ef database update

i get

cannot find command 'dotnet ef

then i did run the command

dotnet tool uninstall --global dotnet-ef

then i tried with

dotnet ef database update

again then i got this error

The application to execute does not exist: 'C:\Users\MyUser\.dotnet\tools\.store\dotnet-ef\2.2.0-rtm-35687\dotnet-ef\2.2.0-rtm-35687\tools\netcoreapp2.2\any\dotnet-ef.dll'.

and when i have checked this path i found that it installs it as

C:\Users\MyUser\.dotnet\tools\.store\dotnet-ef\2.2.0\dotnet-ef\2.2.0\tools\netcoreapp2.2\any\dotnet-ef.dll without -rtm-35687

so i had to rename the folders manually to match and it worked fine

@ajcvickers
Copy link
Member

@AhmedHemdan21 The more appropriate workaround is to install with a preview version specified, as shown above and in the announcement.

@shawty
Copy link

shawty commented May 9, 2019

I concur with @ajcvickers renaming and/or messing about with the paths, folders and installed commands can never be a good thing, using the version suffix above is the safest way of ensuring you don't break anything even accidentally.

@BrettBaggott
Copy link

The workaround for .NET Core 3.0 SDK users is to run

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

I'm sure anyone reading through all this would understand this but what you really should do is head to Nuget and use the latest version (assuming you've just installed the latest 3.0 preview SDK), which for me, getting here after installing preview5 was not what is referenced, of course. I went here and checked:

https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/3.0.0-preview5.19227.1

and used preview5 instead.

Just worth being explicit just in case ;-)

@bill-barron
Copy link

I was working on an older app .net core 2.0 and for me the solution was

dotnet tool uninstall --global dotnet-ef

followed by

dotnet tool install --global dotnet-ef --version 2.1.0

Then I could run

dotnet ef database update --context ApplicationDbContext

@mzrks
Copy link

mzrks commented Jul 3, 2019

The workaround for .NET Core 3.0 SDK users is to run

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

Where I can find a list with all versions of dotnet tools?

@shawty
Copy link

shawty commented Jul 3, 2019

There's not an "Official one" that I know of, but the tools usually follow the version on the runtime lib your trying to use, so

https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/3.0.0-preview5.19227.1

Gives you the NuGet page (and thusly the version) for preview 5, and if you scroll down you'll see the versions for the other previews too.

Copying those versions should (In theory) work.

@bricelam
Copy link
Contributor

bricelam commented Jul 3, 2019

@mzrks Use --version 3.0.0-* to get the latest.

@shawty
Copy link

shawty commented Jul 3, 2019

Cheers Brice, I knew you'd have the answer :-)

@mzrks
Copy link

mzrks commented Jul 3, 2019

There's not an "Official one" that I know of, but the tools usually follow the version on the runtime lib your trying to use, so

https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/3.0.0-preview5.19227.1

Gives you the NuGet page (and thusly the version) for preview 5, and if you scroll down you'll see the versions for the other previews too.

Copying those versions should (In theory) work.

Thank you, it really works.

@prakash-manit
Copy link

FInally, the fix worked for me was renaming the folder names that dotnet ef was creating.
The folder that dotnet ef has created: C:\Users\pratripathi.dotnet\tools.store\dotnet-ef\2.2.6\dotnet-ef\2.2.6\tools\netcoreapp2.2\any
The folder that dotnet ef was trying to access: C:\Users<User>.dotnet\tools.store\dotnet-ef\2.2.6-servicing-10079\dotnet-ef\2.2.6-servicing-10079\tools\netcoreapp2.2\any
Hope above fix helps to the folks who don't want to use preview releases

@antonioortizpola
Copy link

@prakash-manit I would strongly suggest to install the right version to avoid the issues as @shawty suggest.

From my experience and what I am seeing in the post, the best solution for this problem is to check your highest net core version and install that EF version as @BrettBaggott suggest

@vscodewinodws
Copy link

for Me it was the path 2.2.0 servicing , but servicing was missing so just renamed at 2 place and it worked for me , on .net core 2.2

@evan-boissonnot
Copy link

@antonioortizpola the same here :)

@ghost
Copy link

ghost commented Oct 31, 2019

and when i have checked this path i found that it installs it as

C:\Users\MyUser\.dotnet\tools\.store\dotnet-ef\2.2.0\dotnet-ef\2.2.0\tools\netcoreapp2.2\any\dotnet-ef.dll without -rtm-35687

so i had to rename the folders manually to match and it worked fine

I have the same problem. Did you rename the folders? Not some configuration files? Is it safe? I see version of dotnet-ef.dll matches.

@EmKayUltra
Copy link

EmKayUltra commented Nov 17, 2019

Had the same problem (Windows machine):

  1. Had a 2.2.* dotnet SDK installed (and a 2.2 project). Everything was great.
  2. Installed dotnet SDK 3.0.100
  3. dotnet ef "Could not execute because the specified command or file was not found."
  4. dotnet tool uninstall --global dotnet-ef did not do anything because dotnet-ef was not found
  5. dotnet tool install --global dotnet-ef --version 2.* installed 2.2.6
  6. dotnet ef "The application to execute does not exist: 'C:\Users\emkayultra.dotnet\tools.store\dotnet-ef\2.2.6-servicing-10079\dotnet-ef\2.2.6-servicing-10079\tools\netcoreapp2.2\any\dotnet-ef.dll'.
  7. Renamed _C:\Users\emkayultra.dotnet\tools.store\dotnet-ef\2.2.6\dotnet-ef\2.2.6\tools\netcoreapp2.2_ to _C:\Users\emkayultra.dotnet\tools.store\dotnet-ef\2.2.6-servicing-10079\dotnet-ef\2.2.6-servicing-10079\tools\netcoreapp2.2_
  8. dotnet ef now works.

First question: Why is this happening? Is it because dotnet ef is no longer part of the default SDK as of 3.0? Shouldn't they live in isolation from each other?
Second question: How is this acceptable? Seems like a ludicrous solution to the problem.

Related? #14016 @bricelam

@shawty
Copy link

shawty commented Nov 17, 2019

@EmKayUltra I'm not in any way speaking on behalf of Microsoft or the Entity framework team here, but this is NO LONGER an issue.

Let me explain.

When I first opened this issue, I was unaware of how the versioning for the preview versions of dotnet core worked with regards to loadable tools.

Since then, I've done my research and spoken to many members of various MS development teams who have confirmed that tool versions are always set to match dotnet core versions.

This has nothing to do with MS separating out the tools, but it has everything to do with them enforcing matching versions so that you get the correct tool for the version of dotnet you are using.

If for example, you install a supported version of dotnet core 2.2, then simply do "dotnet tool install --global dotnet-ef", the version of dotnet-ef that will be installed on your machine will be version 2.2

If you then install dotnet core 3.0 without uninstalling anything else, your default working version of dotnet core will be set to version 3.0

At this point, dotnet-ef will cease to work, and the reason for this is because you at that point will not have a v3.0 compatible version of the tool installed.

If however you then once again do "dotnet tool install --global dotnet-ef" you'll find that you will regain use of the ef tool, only this time it will be version 3.0 and not the 2.2 version you have been using.

The same is also true for any templates you have installed. I've actually created a small batch file with all my

"dotnet tool install ..."
and
"dotnet new install ..."

statements in, and I run it every time I update my dotnet core SDK version, thus ensuring that I have the latest versions of anything I have added to the install.

You will ONLY get problems installing these tools, in 2 specific scenarios:

  1. Your installing against a preview version and the tool and/or template is not available with a preview version (This was my problem the first time round)
  2. Your trying to do specific versioning using suffixes like "--version 2.x." and the version your targeting is not available (EG: if your active sdk is v3.0 and you try to use "--version 2.0." your install will fail)

In the case of (1) above, if you do a plain old "dotnet tool install --global dotnet-ef", and your on an sdk preview and/or unsupported build, you will also see problems relating to not finding the tool.

The MS team (If you read above) have closed this issue way back in October, as there's nothing to answer here, there is no issue, no fault, no bug or anything.

The only reason I know this keeps getting hits is because as the original author GitHub notifies me every time there is a change on it.

So finally I ask only this:
Those folks who end up here because they are having trouble making the ef tool work, please read the whole thread before you post anything to it.

If after reading it all, you still believe that you've encountered a bug, then open a new issue in the issue tracker, and reference this thread.

Adding your "i have a bug" post to this thread is NOT going to get you the answer or the assistance you seek, because it's now a closed issue.

@jameka23
Copy link

What worked for me was uninstalling dotnet ef and installing again

@TomCJones
Copy link

TomCJones commented Apr 13, 2020

this still seems to a problem in converting from 2.2 to 3.1.3 - i get preview 2.1 and the error
install did not work until i did uninstall first

@fthomas137
Copy link

I had the same issue with .NET Core 2.2 after i have installed .NET Core 3.0 Preview

when i try to execute

dotnet ef database update

i get

cannot find command 'dotnet ef

then i did run the command

dotnet tool uninstall --global dotnet-ef

then i tried with

dotnet ef database update

again then i got this error

The application to execute does not exist: 'C:\Users\MyUser\.dotnet\tools\.store\dotnet-ef\2.2.0-rtm-35687\dotnet-ef\2.2.0-rtm-35687\tools\netcoreapp2.2\any\dotnet-ef.dll'.

and when i have checked this path i found that it installs it as

C:\Users\MyUser\.dotnet\tools\.store\dotnet-ef\2.2.0\dotnet-ef\2.2.0\tools\netcoreapp2.2\any\dotnet-ef.dll without -rtm-35687

so i had to rename the folders manually to match and it worked fine

A hack a day keeps the doctor away - thanks for posting this.

@karin-source-code
Copy link

I got the same type of error, but it was because I had set the wrong startup-project in my command... :facepalm

@ajcvickers ajcvickers added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label Mar 10, 2022
@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
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. customer-reported
Projects
None yet
Development

No branches or pull requests