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.7 KiB
1.7 KiB
SQL Server Database Migration Guide
This guide will help you manage SQL Server 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 SQL Server 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 SQL Server database context from the menu:
[3] LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer -
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.SqlServer/
3. Apply Migration
Generated SQL scripts can be applied to database through:
- Using SQL Server Management Studio or other SQL Server client tools to execute SQL script
- Or using command line:
sqlcmd -S your_server -d your_database -i your_script.sql