You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.6 KiB
1.6 KiB
MySQL Database Migration Guide
This guide will help you manage MySQL database migrations using the migration scripts.
Prerequisites
- Ensure .NET Core SDK is installed
- Ensure Entity Framework Core tools are installed
dotnet tool install --global dotnet-ef - Ensure MySQL connection string is properly configured
Usage Instructions
1. Create New Migration
-
Run the migration script in the
aspnet-core/migrationsdirectory:# Use English version .\MigrateEn.ps1 # Or use Chinese version .\Migrate.ps1 -
Select MySQL database context from the menu:
[1] LY.MicroService.Applications.Single.EntityFrameworkCore.MySql -
Enter migration name (optional):
- Press Enter to use default name:
AddNewMigration_yyyyMMdd_HHmmss - Or enter custom name, e.g.:
AddNewFeature
- Press Enter to use default name:
2. Generate SQL Script
After creating the migration, the script will ask if you want to generate SQL script:
- Choose whether to generate SQL script (Y/N)
- If Y is selected, following options will be available:
[A]- Generate SQL script for all migrations[L]- Generate SQL script for latest migration only[0-9]- Generate from specified migration version
Generated SQL scripts will be saved in:
aspnet-core/InitSql/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/
3. Apply Migration
Generated SQL scripts can be applied to database through:
- Using MySQL client tools to execute SQL script directly
- Or using command line:
mysql -u your_username -p your_database < your_script.sql