This writeup will provide you insights into the database migration command which is crucial for the code first approach using two methods: the Windows CLI and Visual Studio Package manager console.
Method 1- Using Package Manager
Adding Migration
add-migration FirstMigrationUpdating database with latest changes of database script
Update-databaseRemoving the migration-it removes the last migration
remove-migrationDrop database
drop-databaseGenerating SQL Script
script-migrationMethod 2- Using Windows CLI
Adding Migration
dotnet ef migrations add FirstMigrationUpdating database with latest changes of database script
dotnet ef database updateRemoving the migration
dotnet ef migrations removeDropping database
dotnet ef drop databaseGenerating SQL Script
dotnet ef migration scriptTo recapitulate, we have learned the most important and common command for database migration code first approach. I hope, it will be helpful for you to utilize it especially; if your project is based on the code first approach.
