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

Tahir77667 1 Reputation point
2021-05-17T10:32:48.23+00:00

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.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,396 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,188 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yogi 346 Reputation points
    2021-06-06T19:39:56.25+00:00

    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.

    1 person found this answer helpful.
    0 comments No comments