When I started a project (an Identity Server 4 server) I created an ApplicationDBContext (which inherits from ASP.NET IdentityContext and hassome custom tables) and used the ConfigurationDBContext as well as the PersistedGrantDBContext from Identity Server 4. I created 3 migrations (one for each DBContext). Though the data is in the same database (so a single database).
Now I refactored my code giving me a new DBContext having all 3 databases in one DBContext.
My problem is the new migration.
So far I deleted the old DBContexts and created a migration that creates the exact same database again when I run it against an empty database.
But when it comes to migrate an existing database (with existing data) it raises the exception that table X already exists.
I assume this is because I have deleted the old code and the old migrations.
So, how can I create a migration that merges 3 different DBContexts into a single new DBContext.
I assume if I leave the old code in place and use the old migrations too it tries to create the tables multiple times (since they are in the old splitted migrations and the new combined migration)?
Is there a way to tell the new migration to not throw an error if the table exists (and take the table as it is since it is the same layout).
In my opinion, you have to keep 3 default(old) contexts.
Because: It's a very bad practice to merge 3 in 1 and retire their default contexts.