EF Core Error - No project was found. Change the current working directory or use the --project option

sometimes you need to change the current directory in console/terminal eg:

PM> cd E:\Projects\CrossTest\
PM> dotnet ef migrations add InitialMigration

and Align your package versions. Either use preview1 packages or preview2. Mix of those are not supported.


It simply Means that

YOU ARE NOT IN CURRENT PROJECT DIRECTORY

I was facing the same issue when scaffolding existing database of MySql using this.

Command I was executing:

dotnet ef dbcontext scaffold "Server=123.1.1.1;Uid=abc;Pwd=abc;Database=myDB;Connection Timeout=20;Persist Security Info=False;Port=3306;Allow User Variables=True;Connect Timeout=120;" MySql.Data.EntityFrameworkCore -o Models

Causing the same error , then I checked current working directory inside package manager console and found incorrect.

In my case

enter image description here

Mean I was not in current project directory then after switching directory

cd SSGCApp

Now you are in project directory all good to run the Command.


Instead of:

"tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet":"1.0.0"
  },

try:

"tools": {
      "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.0.0-preview3-final"
  }},