Stop using generic migration names! Use descriptive names that explain what changed in your database schema. Your future self (and your team) will thank you.
The Problem
Which migration would you rather see 6 months from now?
β Generic Names
20250505120000_UpdateUser
20250506140000_AddColumns
20250507160000_FixDatabase
What was updated? Which columns? What was fixed?
β Descriptive Names
20250505120000_AddEmailVerifiedToUser
20250506140000_AddCreatedAtUpdatedAtToProducts
20250507160000_FixUserEmailUniqueIndex
Crystal clear what each migration does!
Best Practices
π― Naming Convention
Use this pattern: [Action][What][Where]
- Action: Add, Remove, Update, Fix, Create, Drop
- What: The specific change (column name, index, etc.)
- Where: The table/entity being modified
Examples by Type
Adding Columns
# β Generic
dotnet ef migrations add UpdateUser
# β
Descriptive
dotnet ef migrations add AddLastLoginToUser
dotnet ef migrations add AddIsActiveColumnToProducts
Indexes and Constraints
# β
Clear purpose
dotnet ef migrations add AddUniqueIndexOnUserEmail
dotnet ef migrations add AddForeignKeyOrderToCustomer
dotnet ef migrations add RemoveOldUserNameIndex
Schema Changes
# β
Explains the change
dotnet ef migrations add RenameUserNameToUsername
dotnet ef migrations add ChangeUserEmailToNullable
dotnet ef migrations add SplitAddressIntoMultipleColumns
π‘ Pro Tips
- Use PascalCase for migration names
- Be specific about the table/entity name
- Include the column name when relevant
- Use action verbs (Add, Remove, Fix, Update)
- Keep it under 50 characters when possible
Real-World Examples
# Database cleanup
dotnet ef migrations add RemoveUnusedUserProfileColumns
# Performance improvement
dotnet ef migrations add AddIndexOnOrderDateForReports
# Bug fixes
dotnet ef migrations add FixCascadeDeleteOnUserOrders
# New features
dotnet ef migrations add AddAuditFieldsToAllTables
π Quick Test
Can someone understand what your migration does without looking at the code? If not, improve the name!
π¬ Comments & Reactions