Prerequisites
- What is your product version? 6.9.0
- What is your product type (Angular or MVC)? Angular
- What is product framework type (.net framework or .net core)? .net core
Looking at [Question #6960](https://support.aspnetzero.com/QA/Questions/6960/Apply-migrations-update-database-on-application-start) The provided answer is awesome, but it looks like it only runs migrations for the HOST database, and I'm trying to adapt this for a MultiTenant setup.
So I have 2 questions:
Referencing the code in the
MultiTenantMigrateExecuter.cs
class in the Migrator project, do you foresee any issues retrieving the list of Tenants that have separate connectionStrings, and runningCreateOrMigrateForTenant
?Would running migrations at this PostInitialize method of the XXXEntityFrameworkCoreModule possibly have any interference with
IBackgroundJobManager
? Would it be advisable to resolve the IBackgroundJobManager and call.Stop
and.WaitToStop
before running the Migrator functions? (and then calling.Start
again when migrations are complete) ?
Thanks!
3 Answer(s)
-
0
Hi @sedulen
- When the app starts, the database will not be migrated with the latest migrations, so you might get an exception before executing the migrations.
- I think, if you don't get an error on step 1, this will be fine.
But, if there is no special reason for implementing this, we suggest running Migrator to update databases.
-
0
thanks @ismcagdas
so the concern is that parts of the application may start before migrations are completed, and that may cause an exception?
understood on the suggestion of running the Migrator to update the databases.
what I'm working on is a way to hot-swap Docker Containers, either through AKS or Azure AppServices, where I can deploy an upgrade to the application to a deployment slot, or to a second set of Docker Containers, warm them up, and then hot swap the traffic over to the new instances.
so having the ability for the application to self-migrate would be a huge help.
in looking at the documentation provided for wiring up ANZ into Azure DevOps Pipelines, we don't have connectivity to the SQL database. That connectionString is private to our hosting environment. So for using the Migrator or for generating the EF Migration SQL Scripts, we don't have access to the SQL DB in our DevOps pipeline.
-
0
Hi @sedulen
Thank you for the explanation. I understood the point. AspNet Zero's Azure DevOps documentation uses script generation but I suggest deploying Migrator app to Azure so it can access the database. Does that work for you ?
If that doesn't work, we can work on running migrations on app startup. At least, we can try to create a tutorial or document for it. Please let us kınow if deploying Migrator to Azure works for you or not.