EF6 dynamically instantiate DbContext

300 views Asked by At

Using Entity Framework 6 in Code-First, i'm working on a set of web applications to be used by a group of companies. Each company will have one database and their own DBContext to connect to it with.

The number of contexts and their names is only known by a config database which lists every company and the name of the DBContext that can access their data. I am trying to instantiate each of these contexts from some information stored in the config database. I was attempting to do this with a string context name but this requires some use of System.Activator.CreateInstance which is raising some concerns and complications. Is there a better method to achieve this task?

0

There are 0 answers