C
C#9mo ago
V0FBU1VM

✅ 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
Pobiega9mo ago
VersionPrefix_JiraTicketName_ShortDescription is what we use at work 🙂
V0FBU1VM
V0FBU1VMOP9mo ago
@Pobiega Could you give an example if possible?
Jimmacle
Jimmacle9mo ago
i just name mine something related to what they do
Pobiega
Pobiega9mo ago
007_005_BA_5871_Local_identifiers
V0FBU1VM
V0FBU1VMOP9mo 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
Jimmacle9mo 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
V0FBU1VM
V0FBU1VMOP9mo ago
I see, I didn't know that. Thanks mate.
Jimmacle
Jimmacle9mo 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 User9mo ago
Message Not Public
Sign In & Join Server To View
V0FBU1VM
V0FBU1VMOP9mo ago
:A_pepelaugh: I guess, I should remove the Migrations/ from .gitignore :kekw:
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacle9mo ago
100% migrations are a permanent part of the project
V0FBU1VM
V0FBU1VMOP9mo ago
Thanks again boys. Cheers
Want results from more Discord servers?
Add your server