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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user