I'm working on a multi-tenant application for which we decided to have a database per tenant. I'm coding a service to create and initialize a new database for a new client. Multiple contexts are defined on the same DB. So far I've used nuget update-database to have all the contexts create their db objects. Now I need to do the same at runtime. I tried:
context.Database.Initialize(false);
context.Database.CreateIfNotExists();
But only the first context creates its table. I know that a context initializes the db on the first use but apparently it doesn't if the db already exists. I tried several initializers with no luck. I don't want to code a new context which combines all other contexts because it would be difficult to maintain. I know another option would be generating sql scripts at deployment and executing them at runtime. This would be my last resort.
Any suggestion is highly appreciated.