C
C#β€’4mo ago
SwaggerLife

βœ… How should I name my ef core migrations?

I'm wondering if there is a good way to name your migrations. I have noticed that, you quickly end-up with a lot of migrations. I'm just wondering if there is a good naming convention.
13 Replies
Pobiega
Pobiegaβ€’4mo ago
VersionPrefix_JiraTicketName_ShortDescription is what we use at work πŸ™‚
SwaggerLife
SwaggerLifeβ€’4mo ago
@Pobiega Could you give an example if possible?
Jimmacle
Jimmacleβ€’4mo ago
i just name mine something related to what they do
Pobiega
Pobiegaβ€’4mo ago
007_005_BA_5871_Local_identifiers
SwaggerLife
SwaggerLifeβ€’4mo ago
I see, thanks for the insights guys. What would happen if you lose you migrations or delete it. I have noticed, after deletion. If you do a migrations to an existing database. It says for instance, Product table already exists Is there a way to tell ef core when updating the database to ignore already defined tables?
Jimmacle
Jimmacleβ€’4mo ago
if you lose/delete migrations then EF won't know how to get your database to its "current" state anymore and if you delete the snapshot too, it won't know the current state at all so don't delete/lose them
SwaggerLife
SwaggerLifeβ€’4mo ago
I see, I didn't know that. Thanks mate.
Jimmacle
Jimmacleβ€’4mo ago
an exception would be if you're working on another branch and want to condense your migrations into a single one, then you can delete them, revert the snapshot to whatever's upstream, then create a single new migration but any migrations that have been applied to a real live database you care about should be kept
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
SwaggerLife
SwaggerLifeβ€’4mo ago
:A_pepelaugh: I guess, I should remove the Migrations/ from .gitignore :kekw:
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacleβ€’4mo ago
100% migrations are a permanent part of the project
SwaggerLife
SwaggerLifeβ€’4mo ago
Thanks again boys. Cheers