When creating a new migration in a .NET project using EF Core, follow these naming rules:
- Keep it short. The name should be concise: ideally up to 10 characters, with a maximum of 30. Examples:
AddVerifyInfo,EntityAddSystemProperty. - Use meaningful English. The name should be clear and self-explanatory for an English-speaking developer. Examples:
AddVerifyInfo,DigitalSignChangeFK. - Ensure uniqueness. Migration names must be unique within the project.
- Use PascalCase. Write names in PascalCase, without spaces, underscores, or special separators. Examples:
AddLogoSettings,AddVerifyInfo. - Be consistent. Use a unified naming approach. All migrations should follow the same pattern and be stored in the
Migrationsfolder. - Avoid special characters. Do not use symbols like
@,#,&, etc. Invalid examples:name@,name#,name&. - Don’t include dates. Dates are added automatically when a migration is created and should not be part of the name.
Examples
Incorrect:
Add-Migration Add_New_column_to_some_tableAdd-Migration addSmthToSmwhrAdd-Migration "Create new migration"Add-Migration VeryVeryLongAndSenselessMigrationNameAdd-Migration Some@migration-nameAdd-Migration 20201013_CreateMigration
Correct:
Add-Migration CreateTableEntityTypeAdd-Migration EntityAddColumnTypeAdd-Migration FieldRenameColumnName