I have a database that contains an unknown number of schemas, each schema has the exact same tables.
Is there anyway to change the schema at runtime when creating a new instance dbContext? I know it's possible to change connection strings at runtime, however the schema names is stored in another database as a table of configurations.
I saw that in EF6 you can set a defaultSchema when overriding OnModelCreating
however I am not too sure if this is guaranteed to run everytime I use using (DatabaseContext db = new DatabaseContext()){}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema(SchemaName);
}