I have a standardized all table and column names in my EF Core database to use snake_case. I was able to change the migrations history table name and schema to match the res
Here is an example of how to do it on SQL Server.
First, create a custom implementation of SqlServerHistoryRepository
overriding ConfigureTable
.
class MyHistoryRepository : SqlServerHistoryRepository
{
public MyHistoryRepository(
IDatabaseCreator databaseCreator, IRawSqlCommandBuilder rawSqlCommandBuilder,
ISqlServerConnection connection, IDbContextOptions options,
IMigrationsModelDiffer modelDiffer,
IMigrationsSqlGenerator migrationsSqlGenerator,
IRelationalAnnotationProvider annotations,
ISqlGenerationHelper sqlGenerationHelper)
: base(databaseCreator, rawSqlCommandBuilder, connection, options,
modelDiffer, migrationsSqlGenerator, annotations, sqlGenerationHelper)
{
}
protected override void ConfigureTable(EntityTypeBuilder<HistoryRow> history)
{
base.ConfigureTable(history);
history.Property(h => h.MigrationId).HasColumnName("migration_id");
history.Property(h => h.ProductVersion).HasColumnName("product_version");
}
}
Then replace the replace the service with your custom implementation.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options
.UseSqlServer(connectionString)
.ReplaceService<SqlServerHistoryRepository, MyHistoryRepository>();