dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.59k stars 1.95k forks source link

No project was found. Change the current working directory or use the --project option. #737

Closed niyeshiw closed 6 years ago

niyeshiw commented 6 years ago

i want to use migrations to create the database from my model, i run dotnet ef migrations add InitialCreate,but it show "No project was found. Change the current working directory or use the --project option".what should i do?

ajcvickers commented 6 years ago

@niyeshiw You should change the current working directory (so you're in the project directory) or use the --project option.

eSPiYa commented 5 years ago

I'm experiencing the same issue. My project is already selected as Default project but I'm receiving the same error. I also used the --project option but still don't work: dotnet ef migrations add InitialCreate --project "C:\path_to_my_project\MyProject.csproj" or even dotnet ef migrations add InitialCreate --project="C:\path_to_my_project\MyProject.csproj"

I'm using VS2017 and .NET Core 2.1

ajcvickers commented 5 years ago

@eSPiYa Please file a new issue and include a project/solution that demonstrates the behavior you are seeing.

Elvin1492 commented 5 years ago

@eSPiYa , I get same issue. Could you find any solution?

ageisen2000 commented 5 years ago

I'm also getting this issue. Was there a solution?

I'm using this command:

dotnet ef migrations script --verbose -i --project "C:\path\to\proj\proj.csproj"

nhat-tong commented 5 years ago

@Elvin1492 , @ageisen2000: I think that we had a problem with EF Core Tools v2.1 rtm. I found a work around: you open a new command line and cd to directory that you would like to run the migrations.

cd "D:{path_to_your_projet}" dotnet ef migrations add initial

That should be working.

alexagranov7 commented 5 years ago

I'm having the same issue:

PM> dotnet ef Scaffold-DbContext No project was found. Change the current working directory or use the --project option.

Despite having Default Project set. Using EF Core 2.2

RockmanR commented 4 years ago

The provided solution didn't help me. I've faced the same issue and done a workaround for it.

Instead of using the Package Manager Console, I've used the command line in that same folder . Then 'dotnet' it gave me a helpful error message: (yours might be different)

No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.

Then I moved on to do the configuration steps.

ehsansajjad-synergy commented 4 years ago

What is the solution, i am experiencing same issue in .NET core 3.2 console application

ajcvickers commented 4 years ago

@ehsansajjad-synergy Please open a new issue and include a small, runnable project that reproduces the behavior you are seeing.

bblan42 commented 4 years ago

I had trouble with this too, but I moved one level further into the directory of the project. Instead of "/Users/xxx/Projects/RazorPagesMovie" I moved to "/Users/xxx/Projects/RazorPagesMovie/RazorPagesMovie" and ran the dotnet ef migrations add initial command and got a successful build...

LegionsMan commented 3 years ago

I had trouble with this too, but I moved one level further into the directory of the project. Instead of "/Users/xxx/Projects/RazorPagesMovie" I moved to "/Users/xxx/Projects/RazorPagesMovie/RazorPagesMovie" and ran the dotnet ef migrations add initial command and got a successful build...

this is legit. and if your using mac don't forget to cd to change the directory.

qDonl commented 3 years ago

The run path must be in the <Yourproject>.csproj sibling directory

Nang13 commented 1 year ago

dotnet ef migrations add InitialCreate --project ProjectName(replace by your projectName using EF)

mrozma85 commented 1 year ago

do not use Nuget console. Click on right on your project name in solution explorer and Open in Terminal...

agronsverkaj commented 1 year ago

I had this problem too, but I solve it

  1. right click in project - open in terminal - writte command - dotnet ef migrations add MyFirstMigration thank you mrozma85