Migrating to EF Core migrations
Hello
I'm rewriting a whole backend from TS into C# and I'm struggling at the migrations part after I scaffolded the db context. How would I start using the migrations system EF Core has without just nuking all the data?
9 Replies
Just do?
If I create an initial migration and try to update the db, it'd try to create every table even though they already exist.
The data won't disappear unless you remove it
Well, back up the database and try
It's not like you're deving on production database anyway
I did try that and it just errors
I was thinking of messing with the migration history table but maybe there's a better way
Could just empty the up and down methods in the migration file
Then I'd have to run the old code to create a new db :/
They're not in sql files since it used kysely migrations
I guess you could just add the first migration to the migrations table, then
So EF thinks it's applied — and it technically is — and go from there
So basically force it?
I guess that's what I'll do if there's no better way
I believe that you should create all entities and relationships, create a new schema, run the migrations and import the data, or just run the migrations in a new schema, and then point to the old schema, so for EF the db will be updated. I hope I helped