When using Entity Framework code first migrations is there a best practice for choosing a name for each migration? For example each name might contain a version number or the change(s) made to the model or both.
Add-Migration Added Manager.Employees
Add-Migration Add_Employee_ManagerId
Add-Migration version 2
Add-Migration v2_Add_Employee_ManagerId
Any tips for selecting a good naming strategy for a project with multiple developers and many migrations?
I found a similar question but no answers.
Accepted AnswerYou cannot rename after applying a migration to Database. But you can delete and add another migration with same name or other name.
Following is the context class. Step 1 − Before running the application you need to enable migration. Step 2 − Open Package Manager Console from Tools → NuGet Package Manger → Package Manger Console. Step 3 − Migration is already enabled, now add migration in your application by executing the following command.
Code First Migrations is the recommended way to evolve your application's database schema if you are using the Code First workflow. Migrations provide a set of tools that allow: Create an initial database that works with your EF model. Generating migrations to keep track of changes you make to your EF model.
By default, EF Core keeps track of which migrations have been applied to the database by recording them in a table named __EFMigrationsHistory . For various reasons, you may want to customize this table to better suit your needs.
In the Microsoft docs it states:
The migration name can be used like a commit message in a version control system. For example, if I made changes to save customer reviews of products, I might choose something like AddProductReviews.
So by their provided example of AddProductReviews
I'm thinking that Upper Camel Case is what Microsoft recommends.
https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With