EF Core Commands
List all migrations
Section titled “List all migrations”dotnet ef migrations list --connection "Data Source=ctlsqlprod.database.windows.net;Initial Catalog=CTLShopFloorDB_Prod;MultipleActiveResultSets=True;persist security info=True;user id=Ctladmin;password=jI4#su#HoGaCqdn#;Application Name=CTL.ShopFloor" -s "./CTLShopFloor.Presentation.WebAPP/CTLShopFloor.Presentation.WebAPP.csproj" -p "./CTLShopFloor.Infrastructure.Persistance/CTLShopFloor.Infrastructure.Persistance.csproj" -c CTLShopFloor.Infrastructure.Persistance.DbContext.RepositoryDbContextAdd Migration
Section titled “Add Migration”dotnet ef migrations add --project CTLShopFloor.Infrastructure.Persistance\CTLShopFloor.Infrastructure.Persistance.csproj --startup-project CTLShopFloor.Presentation.WebAPP\CTLShopFloor.Presentation.WebAPP.csproj --context CTLShopFloor.Infrastructure.Persistance.DbContext.RepositoryDbContext --configuration Debug <MIGRATION_NAME_HERE> --output-dir Migrations/RepositoryDbRevert/Update Database
Section titled “Revert/Update Database”dotnet ef database update --project CTLShopFloor.Infrastructure.Persistance\CTLShopFloor.Infrastructure.Persistance.csproj --startup-project CTLShopFloor.Presentation.WebAPP\CTLShopFloor.Presentation.WebAPP.csproj --context CTLShopFloor.Infrastructure.Persistance.DbContext.RepositoryDbContext --configuration Debug <PREVIOUS_MIGRATION_NAME>Remove Last Migration
Section titled “Remove Last Migration”dotnet ef migrations remove --project CTLShopFloor.Infrastructure.Persistance\CTLShopFloor.Infrastructure.Persistance.csproj --startup-project CTLShopFloor.Presentation.WebAPP\CTLShopFloor.Presentation.WebAPP.csproj --context CTLShopFloor.Infrastructure.Persistance.DbContext.RepositoryDbContext --configuration Debug