feat: disable identity auto-generation for reference/lookup tables

Reference tables (Province, City, BasicTable, IncomeCostTitle, UnitState, Transaction) require stable, manually assigned IDs that are cross-referenced by other entities. Identity auto-generation is disabled to allow explicit ID assignment from seed data.
This commit is contained in:
2026-06-09 02:40:13 +03:30
parent 6644db7e78
commit 0e1b0345ec
4 changed files with 74 additions and 79 deletions

View File

@@ -77,6 +77,43 @@ namespace Complex.Infrastructure
.WithMany()
.HasForeignKey(uc => uc.UnitId)
.OnDelete(DeleteBehavior.NoAction);
// ============================================================
// Reference/Lookup tables: These have fixed, meaningful IDs
// that are explicitly set in seed data and cross-referenced
// by other entities. Identity auto-generation must be disabled.
// ============================================================
// Province: ProvinceId (1-31) are stable identifiers
builder.Entity<Province>()
.Property(p => p.ProvinceId)
.ValueGeneratedNever();
// City: CityId (101, 102, ...) are meaningful (provinceId * 100 + index)
builder.Entity<City>()
.Property(c => c.CityId)
.ValueGeneratedNever();
// BasicTable (base for TransactionType): Id (1,2) are fixed reference data
builder.Entity<BasicTable>()
.Property(b => b.Id)
.ValueGeneratedNever();
// IncomeCostTitle: Id (1-12) are fixed reference data
builder.Entity<IncomeCostTitle>()
.Property(i => i.Id)
.ValueGeneratedNever();
// UnitState: Id (1-5) are fixed reference data
builder.Entity<UnitState>()
.Property(u => u.Id)
.ValueGeneratedNever();
// Transaction: Seeder uses explicit IDs (1,2,3) that are
// cross-referenced by UnitCost.TransactionId
builder.Entity<Transaction>()
.Property(t => t.Id)
.ValueGeneratedNever();
}