Search code examples
asp.net-core-2.0multi-tenantentity-framework-migrationsaspnetboilerplatemulti-database

How Do I Migrate Tenant Databases and Host Database in Asp.NET ZERO / Boilerplate?


I am using the ASP.NET ZERO framework with ASP.NET Core and Angular for my current project.

I am also using the 'MultiTenancy - MultiDatabase' feature of ASP.Net ZERO.

In application I have added a 'Tenant1-Database' connection string in create new Tenant.

enter image description here

Now i have two databases:

  1. Host-Database
  2. Tenant1-Database

When I create a new Tenant, 'Tenant1-Database' is automatically update as per previous migration files.

But when I update the model with a new property and try to migrate the database using code-first approach, I see that 'Host-Database' is the only db migrated with the new properties and Tenant1-Database is not migrated.

My question is: How can I migrate into both databases using a single migration file?


Solution

  • Yeah.. I Got the Solution

    In the ASP.Net Zero, whole sample template have project with Projectname.Migrator

    ASP.Net Zero already provides the Host database and all Tenant Databases migrations by console application

    Just need to Create a migration file and execute project with Projectname.Migrator