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
Migrations
folder. - 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_table
Add-Migration addSmthToSmwhr
Add-Migration "Create new migration"
Add-Migration VeryVeryLongAndSenselessMigrationName
Add-Migration Some@migration-name
Add-Migration 20201013_CreateMigration
Correct:
Add-Migration CreateTableEntityType
Add-Migration EntityAddColumnType
Add-Migration FieldRenameColumnName