using FluentNHibernate.Mapping; using Results.Entities; namespace Results.Mappings { public class PurchaseBoxMap : ClassMap { public PurchaseBoxMap() { Table("purchase_boxdata"); Id(x => x.Id); Map(x => x.BoxNo); // Map the foreign key to PurchaseOrder correctly References(x => x.PurchaseOrder) .Column("PurchaseOrderId") // Replace this with the correct column name .Not.Nullable(); HasMany(x => x.PurchaseWaterMeterDataList) .Cascade.All() .KeyColumn("PurchaseBoxId") // This should match the foreign key in `purchase_boxdata` .Inverse() // This is important if `PurchaseBox` holds the foreign key .LazyLoad(); // Optional: Depends on your performance needs } } }