To overcome this we have to find a mechanism to keep alive this migration.
That is, we can run a little bit of SQL code that will create a create an INSERT TRIGGER __EFMigration History table.
Note that, renaming an already run migration invalidates it from __Migration History table, and make it available to execute again.
You can use this technique as many times to execute a specific migration without deleting it in __Migration History.
However, there is a way to rollback to a specific migration, if necessary.
However, rollbacks or reverting schema is barely used feature.
If you are dealing the large database schema, this can be a very risky task.
In this article, we will address the above issues by providing solutions that can overcome the limitation of Entity Framework core migrations (many concepts can also be applied the legacy Entity Framework.) I invented this unique way of doing, when I had to solve a specific problem for managing Temporal Tables.
These migrations are recorded and tracked in a database table called method has code that is run for rolling back changes.This is because the __EFMigration History has now a record of it indicating it is already run.So EF core migrations will never pick this file to run again.First, let’s understand that one can create custom migration class by inheriting from Migration base class.And adding the attributes DBContext to provide context and Migration to give it a name.
The create Employee migration will now run, but it will fail, because that table does exist in database.