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
Anton2y 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
Async-Void2y ago
afaik ef will only apply the new migrations
Anton
Anton2y 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
Async-Void2y ago
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
Anton2y ago
well no it just doesn't, it ran all migrations what could that be?
Async-Void
Async-Void2y ago
hmmm that doesnt seem right maybe ask in #database reacher or superbrain will be more help than me
Anton
Anton2y ago
actually I checked the database, and found the migration history empty which is super weird but that was the culprit probably
Async-Void
Async-Void2y ago
most likely so there is a deeper issue there the history shouldnt be empty
Anton
Anton2y ago
right? if there are tables, there should be at least a row
Async-Void
Async-Void2y ago
well that is why ef is running all migrations because it doesnt think any where already run
Anton
Anton2y ago
yeah
Async-Void
Async-Void2y ago
are you doing ef database update after you add a migration?
Anton
Anton2y ago
yeah it's ok, it's a test database, I've already wiped it
Async-Void
Async-Void2y ago
just wondering why there is no history
Anton
Anton2y ago
just want to get to the bottom of this so that things like this don't happen in production
Async-Void
Async-Void2y ago
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.