title: How can I set the schema dynamically for a Code First DbContext?
body: <p>I have an EF6 Database First application that uses tables generated to an edmx from the dbo schema.</p>
  
  <p>To update certain large pricing tables that work in concert with each other, I create new tables in a new schema based on the date, then inside a transaction, move the current tables to a backup schema, and move the new tables to the dbo schema. This is implemented using a new MetadataWorkspace created by reading the edmx file and changing the schema, and allows me to have two DbContexts where one works with the existing data in the dbo schema, and the other works with the new tables in the new schema. And works great for Database First! 
  <a href="https://stackoverflow.com/questions/24769364/how-can-i-create-a-metadataworkspace-using-metadata-loading-delegates">See this SO article.</a></p>
  
  <p>For CodeFirst, one can set the modelBuilder.HasDefaultSchema in OnModelCreating, but then the DbContext is locked down, and OnModelCreating is not called again for new DbContext instances, so whatever schema was set is now used for all such DbContexts for the duration of the application.</p>
  
  <p>My question is – how can I dynamically change the DbContext with CodeFirst where I can have two DbContext, each using different schema? I cannot just define two DbContext derived classes since the schema name is dynamic.</p>