C
C#14mo ago
OkOk

❔ EF Migration successful but nothing changes

I can see that the commands resulted OK, the migration has the new columns and the database has the new migration in it's history Yet the new columns in the model have not been added to the database I have made migrations many times in this project without problems, attaching relevant pictures and migration (Newest migration is "addSuccessIncrement14" and a new column is "waitDescription") I have tried Clean/Rebuild, and checked GPTs suggestions
33 Replies
Pobiega
Pobiega14mo ago
You attached the wrong file can you show the generated migration file, not the one containing the snapshot for that state
OkOk
OkOkOP14mo ago
It contains empty Up/down-methods so EF didn't detect any changes to generate the migration
Pobiega
Pobiega14mo ago
right thats why your migration does nothing as to WHY ef didnt detect any changes, I cant tell try to remove that migration and check the snapshot does it still contain the "new" column? then its not new
OkOk
OkOkOP14mo ago
@Pobiega Yes the snapchat still contains the "new" column after deletion Altough there was no migrations that contain the addition of the new column Before this, I tried to temporarily change the connection string to another local db, and that db has the new column But not one migration file with up/down contains the name of the column I added another property called testString and migrated, now that column appears in migration/db but not the other new properties
Pobiega
Pobiega14mo ago
curious.
OkOk
OkOkOP14mo ago
Yes right Recognizing new properties but not old ones
Pobiega
Pobiega14mo ago
the snapshot isnt derived from the actual database, its just a... continous evolution of your model
OkOk
OkOkOP14mo ago
Everything is the same, public and whatnot It has to be relating to that temporary copy of the db, that contained all the new columsn Because those will not be added to the original db I think this is a case of software not working as intended, but I should not cast doubt so soon on something so vigorously tested
OkOk
OkOkOP14mo ago
I should learn to read these, but maybe this will lead to a report because I can't see any suggestions for making EF recognize these model changes that I have not yet tried
Pobiega
Pobiega14mo ago
I frankly doubt it, EF is used by millions it might seem weird, but its almost always user error somehow 🙂 have you ever added then removed migrations before, and not via the ef migrations remove command? that could easily "corrupt" your snapshot
fasadin
fasadin14mo ago
if you deleted manually already executed migration then migration table is corrupted. That's probably what's going on, and now it cannot find your changes my question would be. Is it possible for you to reset your migration?
Pobiega
Pobiega14mo ago
exactly
fasadin
fasadin14mo ago
the easiest would be to reset whole history "start" over with one big migration
OkOk
OkOkOP14mo ago
Thank you I think you are right Someone(absolutely not me) has deleted without proper command
Pobiega
Pobiega14mo ago
you could also fix your snapshot manually, via "snapshot surgery"
fasadin
fasadin14mo ago
if that's production code, then you need to manipulate changes in db manually
OkOk
OkOkOP14mo ago
I'm trying to repair as we speak
Pobiega
Pobiega14mo ago
its annoying, but not impossible, to manually edit the snapshot alterantively, make a blank DB, run the latest migration, take that snapshot, go back to your normal code, paste snapshot
OkOk
OkOkOP14mo ago
It's in development
Pobiega
Pobiega14mo ago
and pray to god
OkOk
OkOkOP14mo ago
So I think easiest solution is to start over like you say Sorry god is not on my side
fasadin
fasadin14mo ago
okok, is this running code on production? I mean if you have any migration on production
OkOk
OkOkOP14mo ago
No there is nothing in prod
fasadin
fasadin14mo ago
then it's far better to repair ah, delete all and start over 😄
Pobiega
Pobiega14mo ago
if you are fine with resetting your databases, you could just delete your DBs and all migrations and generate a brand new "initial" migration
fasadin
fasadin14mo ago
excatly it's the quickest solution
Pobiega
Pobiega14mo ago
also, just a heads up
OkOk
OkOkOP14mo ago
This might cause a headache for the people sharing my repository but I will tell them first
Pobiega
Pobiega14mo ago
in a large EF core app with many migrations, compiling the migratons is a HUGE part of your build time so we actually script and merge migrations every now and then its a nightmarish process, but having 400+ migrations that sum up to ~500K lines of code to compile is.... 😄
fasadin
fasadin14mo ago
just tell them to drop and create db after pull
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise 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