Specify which project file to use when inside project directory

user3181843 picture user3181843 · Mar 18, 2018 · Viewed 8.8k times · Source

Trying to use "dotnet ef" command in Package Manager Console. the PMC is cd to the .csproj directory, and still getting:

dotnet : Specify which project file to use because this 'C:\Users\PC-NAME\Source\Repos\TestProject\Test" contains more than one project file.
At line:1 char:1

dotnet ef migrations add TestMigration
  + CategoryInfo          : NotSpecified: (Specify which p...e project file.:String) [], RemoteException
  + FullyQualifiedErrorId : NativeCommandError

Tried use -p / --p and point to the .csproj file / directory - still same error.

Using .NET CORE, MVC project, Latest EF Core 2.0.2 version.

There's no so much valuable data on the internet about that problem, just a wild guess that dotnet ef command is looking for .exe file to run on.

Hoping for help.

Answer

Nader Chebbi picture Nader Chebbi · Apr 27, 2021

If your project contains more than one .csproj file you should move them to another directory other than the project folder and run again your commande line.

In my case I have two .csproj in the project folder : CoreWebApplication.csproj and CoreWebApplication-backup.csproj so I moved the CoreWebApplication-backup.csproj and I kept the CoreWebApplication.csproj

dotnet ef ... -p CoreWebApplication.csproj -s CoreWebApplication.csproj