Entity Framework enable migration based on DbContext situated in another project

In order to create a new locally database to run tests you can create your migrations in the test project by taking in care that you can use your repository db context in another VS project.

To achieve this result you can do the following in the Package Manager Console

Enable-Migrations -ContextProjectName MyProject.Repository -ContextTypeName MyProject.Repository.MyDbContext -ProjectName MyProject.Tests -StartUpProjectName MyProject.Tests -ConnectionStringName "MyConnectionString"
Add-Migration "Init Test Db"
Update-Database -ProjectName MyProject.Tests -StartUpProjectName MyProject.Tests -ConnectionStringName "MyConnectionString"

Update .gitignore file

In order to update the .gitignore file do the following:

Commit the new .gitignore file.

Run these commands:

git rm -r –cached .
git add .
git commit -m “.gitignore update”

Push on the remote branch.