Our project uses Entity Framework Code First. We wish to have an instance where a very simple POCO represents many tables in the database. It is part of a horizontal partiti
You can add a constructor to your DbContext
derivative, having two string arguments for table name and metaschema name. You can store the names in member variables and use them in the ToTable
method.
The DbModel
is created when it is actually needed, so the constructor always runs before the OnModelCreating
event. (This is not always the case in derived classes, but that's a different topic).
As an optimization you can cache compiled DbModel
s and build DbContext
s by the constructor accepting a DbCompiledModel.