First you need to create a “Super” context for the migration configuration.
MySuperContext : DbContext {
Then just create the following class:
public class NoDatabaseInitializer<T> : IDatabaseInitializer<T> where T: DbContext { public void InitializeDatabase(T context) {
now, in each small Context, you add this to the constructor:
class MyUserContext : DbContext { public MyUserContext : base("MyConnectionString")
now you will no longer get this error,
plus, you will have your migration history,
and you will use several contexts in one database.
source share