0
votes

I'm running an asp.net core app with ef core and two environments: prod and dev. I created some migrations and applied them to both environments a while ago, but needed to roll them back in development. After I rolled back in dev, I kept developing and now have many migrations in dev that are not in prod, as well as the reverted migrations in prod that I haven't rolled back yet. So now my environment's migrations look like this:

Prod => a,b,c,d

Dev => a,b,e,f,g

(one major thing to note: the migrations i'm reverting in prod (c,d) are not being used, they were just models I created for future use - that I ended up changing - so loss of data from these migrations is not a concern)

I can't run the same commands I ran initially in dev since i'm not adding any migrations now, I just need to update the prod database to the migrations I have locally.

If I update-database b then update-database will this revert the changes in prod then update to my local migrations? Or will this revert the migrations i've added in visual studio? What are my options here?

1

1 Answers

1
votes

On the production environment run a downgrade to the latest working migration:

Update-Database –Migration b

Then delete the 2 migrations c and d from your migration folder.

Finally you can update to the latest migration on the production enviroment:

Update-Database