πŸ’‘ Developer Tips / Better EF Migration Names
entity-framework

Better EF Migration Names

November 5, 2025 β€’ 1 min read
← Back to Tips
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