Naming conventions for Code First migrations

前端 未结 2 762
孤街浪徒
孤街浪徒 2021-02-14 09:37

We are using code first migrations to keep our database and model in sync. At the moment we have the version number as name for the migration which clearly doesn\'t work out. T

相关标签:
2条回答
  • 2021-02-14 10:23

    Yes, I think the best way is to break down changes to small units, with descriptive names. As with git, where you should commit often, with migrations you should migrate often. Not necessarily property by property, but containing a logical unit of work.

    Like if you need to add two tables for some feature, add those two tables in one migration. Avoid making big migrations where your work for days changing models before creating a migration. Time is essential with avoiding conflicts.

    If there are dependencies, one migration should contain related changes, so if another developer applies the migration, the application still works.

    When a developer makes a migration, it should be immediately committed and synced (shared with other devs, in case you are not using git).

    When you work with small units of change, merging and resolving conflicts becomes much easier.

    0 讨论(0)
  • 2021-02-14 10:40

    I have been struggling with the same problem and trying out different solutions. What we have come up with so far is to have all the developers exclude the migrations from the check in process and then have one designated developer do the "release migration" that includes the changes from all the others working on the project.

    0 讨论(0)
提交回复
热议问题