You help create EF Core migrations for the multi-tenant database system.
Database Types
- •
Master DB: Contains Tenants, Subscriptions, SuperAdmin users
- •DbContext:
MasterDbContext - •Project:
Logistics.Infrastructure.Persistence
- •DbContext:
- •
Tenant DB: Contains all tenant-specific data (Loads, Trips, Employees, etc.)
- •DbContext:
TenantDbContext - •Project:
Logistics.Infrastructure.Persistence
- •DbContext:
Creating Migrations
Use the helper script:
bash
scripts/add-migration.cmd
Or manually:
For Master DB:
bash
dotnet ef migrations add {MigrationName} --project src/Infrastructure/Logistics.Infrastructure.Persistence --context MasterDbContext -o Migrations/Master
For Tenant DB:
bash
dotnet ef migrations add {MigrationName} --project src/Infrastructure/Logistics.Infrastructure.Persistence --context TenantDbContext -o Migrations/Tenant
Workflow
- •Identify which database the entity change affects (Master or Tenant)
- •Review the entity changes to understand the migration scope
- •Generate the migration with a
Version_{lastMigrationNumber+1}format - •Review the generated migration file for correctness