question

Tahir77667 avatar image
0 Votes"
Tahir77667 asked yogyogi answered

'EntityFramework.Core.Tools' nuget package installation error: "The process cannot access the file ef.exe because it is being used by another process"

While installing the package Microsoft.EntityFrameworkCore.Tools for using EF in my project using Nuget, I'm persistently running into the below error. Notice I didn't get any error while installing other related packages used for EF core.

  • Microsoft.EntityFrameworkCore

  • Microsoft.EntityFrameworkCore.Relational

  • Microsoft.EntityFrameworkCore.SqlServer

po2rP.png

Here is the location of the file ef.exe

o848q.png

Basically the intention behind installing this package is to use EF command-line tools. I'm currently on Windows 10 and the .NET SDK installed on my machine is 3.1. I had previously 2 SDK's installed on my system(3.1 & 5.0). As per microsoft's documentaion, "The .NET CLI must choose an SDK version for every dotnet command. It uses the latest SDK installed on the machine by default." Therefore I went ahead and uninstalled .NET 5.0 SDK.

FjGnu.png

However, after doing so, I'm even unable to open/load any .NET framework based projects and my VS 2019 installer says that .NET 5 SDK is a required component of VS 2019 to load projects. The real question is "Is .NET 5 SDK causing this i.e. can having multiple SDKs on a single machine cause this kind of issues?"

Here are some of the solutions that I tried:



  1. Deleting the package folder from '.nuget/packages/microsoft.entityframeworkcore.tools' & thereby the executable i.e. 'ef.exe' and reinstalling the same.

  2. Installing the same package using dotnet cli.

  3. Running Visual Studio 2019 as admin.

  4. Deleted the folder "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions"

I have also tried some of the steps mentioned here on github: https://github.com/NuGet/Home/issues/1138.
Any kind of help would be really appreciated.



dotnet-aspnet-core-generaldotnet-runtimedotnet-aspnet-core-mvcdotnet-entity-framework-coredotnet-package-management
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Tahir77667,

Based on your description, I tried to create a new Asp.net core 3.1 application, and then install the Entity Framework Core related package, everything works well. You could try to create a new application to verify it.

Besides, you can also try to use the following methods, and then reinstall the Nuget package:

  1. Check is there any another progress is using the ef.exe, try to end this progress.

  2. Close all the Visual Studio and reopen the application.

  3. Clean the project via the Clean option, and then rebuild the project and install the package.

  4. Tried to use dotnet build-server shutdown.


    Is .NET 5 SDK causing this i.e. can having multiple SDKs on a single machine cause this kind of issues?

About this question, you could try to re-install the Asp.net 5 SDK and runtime on your machine and check the .NET core 3.1 application whether the issue is disappears. On my machine, it seems that the issue does not relate the .NET5 SDK.




0 Votes 0 ·

Hey @ZhiLv-MSFT
Thanks for getting back. I did try to create a fresh new .NET core application with the very first thing of installing this package again but it was the same issue.

  1. Since I'm on windows, I ran the command tasklist on cmd to check whether the program ef.exe was running or not but it wasn't.

  2. I closed the application several times, opened up VS in admin mode, but that didn't work too.

  3. Did a clean → build, no success

  4. I haven't tried out this command yet. Will try it and let you know. What does it do anyway?

Uninstalling .NET 5 SDK doesn't help either. In fact I was unable to even load my project in Visual Studio 2019 after doing that. It seems VS 2019 is tightly integrated to .NET 5.




0 Votes 0 ·

Hi @Tahir77667,

Since, the ef.exe is being used by another progress, for test purpose, you could try to restart your computer, and then recheck whether the issue is solved or not.

Yes, you are right, the latest version of VS 2019 is tightly integrated to .NET 5, if you unchecked the .NET 5 Runtime in the Visual Studio Installer's Individual components panel, the visual studio would remove the component and any items that depend on .NET 5 Runtime. Then, when you create a new application, you can see there doesn't have any asp.net core relates templates to select. So, you could try modifying your VS 2019 and selected the .NET 5 Runtime (Install .NET 5), then check if the application works well.

0 Votes 0 ·
Show more comments

1 Answer

yogyogi avatar image
0 Votes"
yogyogi answered

I got the same problem. I copied the app folder to another directory and then ran the Entity Framework Core installation in the new folder. So this means you will now have to run the project from this new folder and just leave the old folder.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.