Visual Studio Code Entity Framework Core Add-Migration not recognized

You need to add:

dotnet tool install --global dotnet-ef

Im working on Mac, so Ruby is installed by default. My EF commands required lots of extra parameters --project, --startup-project etc. This was a pain to type every time, so I used rake to make this easier.

In my project root, I added a file called rakefile with these contents:

desc "Add Migraion"
task :'add-migration' do
    ARGV.each { |a| task a.to_sym do ; end }  
    puts ARGV[1]
    sh "dotnet ef migrations add " + ARGV[1] + " --project MyProject.Data/MyProject.Data.csproj --startup-project MyProject.Web/MyProject.Web.csproj "
end

desc "Remove Migraion"
task :'remove-migration' do
    ARGV.each { |a| task a.to_sym do ; end }  
    puts ARGV[1]
    sh "dotnet ef migrations remove --project MyProject.Data/MyProject.Data.csproj --startup-project MyProject.Web/MyProject.Web.csproj"
end

desc "Update Database"
task :'update-database' do
    ARGV.each { |a| task a.to_sym do ; end }  
    puts ARGV[1]
    sh "dotnet ef database update --project MyProject.Data/MyProject.Data.csproj --startup-project MyProject.Web/MyProject.Web.csproj"
end

Then at the command line, I run these commands:

rake add-migration <migrationName>
rake remove-migration
rake update-database

Step 1 First we need to add reference in *.csproj file in the following way

Step 2 in Bash/Command propt

dotnet restore

Step 3

dotnet ef migrations add MyDbInitialMigration


The correct format to add a new migration is dotnet ef migrations add yourMigrationName

and to update database is dotnet ef database update