Entity Framework Core - change table schema "__EFMigrationsHistory"

Can I change the __EFMigrationsHistory table __EFMigrationsHistory in the EntityFramework core?

+7
entity-framework-core
source share
2 answers

Do this when calling UseSqlServer .

 optionsBuilder .UseSqlServer( "...", x => x.MigrationsHistoryTable( HistoryRepository.DefaultTableName, "mySchema")); 
+14
source share

A look into the source code ( HistoryRepository.cs ). You can customize tables of tables and diagrams inside the DbContext constructor

 public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { var relationalOptions = RelationalOptionsExtension.Extract(options); relationalOptions.MigrationsHistoryTableName = "bar"; relationalOptions.MigrationsHistoryTableSchema = "foo"; } 

or inside the OnConfiguring method

 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var relationalOptions = RelationalOptionsExtension.Extract(optionsBuilder.Options); relationalOptions.MigrationsHistoryTableName = "bar"; relationalOptions.MigrationsHistoryTableSchema = "foo"; } 
+8
source share

All Articles