C
C#2y ago
Anton

❔ EF Core migrations

Is it normal that when I do ef database update with an unapplied migration, it tries applying all migrations from the start, even though the database already has all of the migrations but the last one? Like it even has a table with migration history so it should automatically detect which migrations haven't been applied yet. Or am I wrong?
17 Replies
Anton
AntonOP2y ago
I think I've renamed some classes, but I left the strings unchanged in the migrations even if I try applying the last migration specifically, it tries doing the ones before it anyway
🦃 Async-Void 》🦃
afaik ef will only apply the new migrations
Anton
AntonOP2y ago
ef core can't change the column type from int to uniqueidentifier like I get why, but how do I work around that? well yeah that's ehat I expected, but something is wrong on my part apparently perhaps changing the names did something? Can I not change the names of anything?
🦃 Async-Void 》🦃
if you change the name in the model then add a new migration ef will then run the new migration and change whatever it needs to change
Anton
AntonOP2y ago
well no it just doesn't, it ran all migrations what could that be?
🦃 Async-Void 》🦃
hmmm that doesnt seem right maybe ask in #database reacher or superbrain will be more help than me
Anton
AntonOP2y ago
actually I checked the database, and found the migration history empty which is super weird but that was the culprit probably
🦃 Async-Void 》🦃
most likely so there is a deeper issue there the history shouldnt be empty
Anton
AntonOP2y ago
right? if there are tables, there should be at least a row
🦃 Async-Void 》🦃
well that is why ef is running all migrations because it doesnt think any where already run
Anton
AntonOP2y ago
yeah
🦃 Async-Void 》🦃
are you doing ef database update after you add a migration?
Anton
AntonOP2y ago
yeah it's ok, it's a test database, I've already wiped it
🦃 Async-Void 》🦃
just wondering why there is no history
Anton
AntonOP2y ago
just want to get to the bottom of this so that things like this don't happen in production
🦃 Async-Void 》🦃
yeah no doubt
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server