'.net 5.0 ef core change default schema of migration history table

Need to change the default db schema of migration history table. Tried to use OnConfiguring like below;

     protected override void OnConfiguring(DbContextOptionsBuilder options)
        => options.UseNpgsql(           
            x => x.MigrationsHistoryTable("__MyMigrationsHistory", "supplier"));
     }

However received;

'OnConfiguring' cannot be used to modify DbContextOptions when DbContext pooling is enabled. error

I'm using IDbContextFactory like this;

           using (IServiceScope scope = host.Services.CreateScope())
            {
                IDbContextFactory<DatabaseContext> contextFactory =
                    scope.ServiceProvider.GetRequiredService<IDbContextFactory<DatabaseContext>>();

                using (DatabaseContext context = contextFactory.CreateDbContext())
                {
                    context.Database.Migrate();
                }
            }

How can I set custom schema for migration history table?



Sources

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

Source: Stack Overflow

Solution Source