'Migration is reapplied while trying remove it

We use context.Database.Migrate(); at runtime (application Main method) to apply migrations. This does not seem to work in conjunction with

Update-Database <RevertToMigration>
Remove-Migration

when trying to revert and remove a migration. The Remove-Migration command ends up calling the same code which re-applies the migration that was just reverted. Am I calling the correct commands? Is there a way to determine in the code whether or not the Remove-Migration command is being called (and therefore skip calling Migrate())? The DbContext is configured using the OnConfiguring method.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source