Multiple migration files for different DBs

At DataCircle we use different database flavors as we need to be able to test and connect to as many as possible. We also employ EF Core and Code First approach to structure our Database and here is the problem. EF generates code that is specific to the database used under the current Context (which for me is a big mistake, but I will elaborate further bellow).

As we currently support MySQL and MSSQL we had to create at least two migration files and the key here is to have multiple DbContext files.

We can use Environments as types but you can easily name them after the database flavor.
For purpose of simplicity we will go on by using Development and Production.

We start by creating the AbstractDbContext.cs which will help with inheritance and DI.

    public abstract class AbstractDbContext : IdentityDbContext<User, Role, int>
        public AbstractDbContext(DbContextOptions options)
            : base(options) { }

        //code omitted for simplicity

Then we implement X amount of YDbContext files based on the AbstractDbContext.cs

    public class DevelopmentDbContext : AbstractDbContext
        public DevelopmentDbContext(DbContextOptions options)
            : base(options) { }

        protected override void OnModelCreating(ModelBuilder builder)
            Console.WriteLine("Database Context: Development");
            //code ommitted for simplicity

It is crucial to modify the Startup.cs file:
* Use correct driver based on ENV
* Add the correct implementation of DbContext

Now it is time to generate the migration files. (I am using Powershell)

dotnet ef migrations add -c ProductionDbContext -e Production InitialCreate  
dotnet ef migrations add -c DevelopmentDbContext -e Development InitialCreate  

It's important to note that as we now have multiple DbContext we need to define the context by providing the -c variable.

Which creates the following files.

The first migration file will always be on route folder location, each subsequent has it's own directory.

And this is it!

A few comments suggestions.
At first I expected EF to create generic migration files that would map based on the target database when applying the changes thus making 1 migration file universal.
I do not see as to why this cannot be done as the mappers already exist.