Search code examples
c#.net.net-coreentity-framework-coremigration

How can i run the add migration command


I installed the following packages:

Microsoft.EntityFrameworkCore.Design(7.0.2)
Microsoft.EntityFrameworkCore.Sqlite(7.0.2)

I already installed Entity Framework Core.

When I tried to run this command:

dotnet ef migrations add InitialMigration

I get this error:

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

I already tried go to the project folder using cd "C:..." it doesn't work.


Solution

  • If you have several projects in one solution or if you have deleted and created a project several times, you may encounter this error (of course, there are other reasons).

    This error occurred because Migration could not automatically determine which project to select.

    You can solve this problem by adding your project name

    dotnet ef migrations add InitialMigration --project TestAPI
    

    enter image description here