<aside> 🔁 Synced from GitHub #9febf8e47c63. Edit in the paidhr-system-docs repository, not here: changes made in Notion are overwritten.
</aside>
All schema changes, for every service that touches SQL Server, ship as core-backend EF Core migrations.
core-backend-service/CLAUDE.md and doc/Migration_Guide.md)Core.Backend.Domain/Entities/Tenant.IEntityTypeConfiguration in Core.Backend.Infrastructure/Configurations/Tenant.TenantDbContext.OnModelCreating with ApplyConfiguration(...).DbSet if needed.dotnet ef migrations add --context TenantDbContext --project src/Core.Backend.Infrastructure …
Do not hand-write it.Migrations/TenantDb. Never in Migrations/Archive: the migrator skips that folder..Designer.cs and the updated TenantDbContextModelSnapshot.cs.Up and Down; Down must reverse Up.SQL-only migrations (stored procedures, functions) put their script under Migrations/TenantDb/Scripts with a copy-to-output entry in the csproj.
Environment=LOCAL ASPNETCORE_ENVIRONMENT=Development \
dotnet run --project src/Core.Backend.Migrator
The migrator decrypts the real connection strings and walks membership, analytics and every tenant. Locally that reaches dev only. Don't use dotnet ef database update: the design-time factory points at a different database on purpose.
🛑 One migration per change
Thirteen small migrations on one feature stalled the develop deploy build. Collapse them before pushing.
sys.sql_modules.definition), change one statement with REPLACE, switch CREATE to ALTER, run with sp_executesql, and guard with a marker string so re-running does nothing. Old migrations that rewrote whole procedures silently dropped each other's columns.