Changeset 1db5673 for FarmatikoData/FarmatikoDataContext.cs
- Timestamp:
- 11/14/20 12:27:30 (4 years ago)
- Branches:
- master
- Children:
- 68454c6
- Parents:
- ad60966
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoDataContext.cs
rad60966 r1db5673 15 15 public virtual DbSet<Pandemic> Pandemics { get; set; } 16 16 public virtual DbSet<Medicine> Medicines { get; set; } 17 //public virtual DbSet<MedicineList> MedicineLists { get; set; }18 17 public virtual DbSet<RequestPharmacyHead> PHRequests { get; set; } 19 18 public virtual DbSet<User> Users { get; set; } 19 public virtual DbSet<PharmacyHeadMedicine> PharmacyHeadMedicines { get; set; } 20 21 protected override void OnModelCreating(ModelBuilder modelBuilder) 22 { 23 modelBuilder.Entity<PharmacyHead>() 24 .ToTable("PharmacyHeads"); 25 26 modelBuilder.Entity<Medicine>() 27 .ToTable("Medicines"); 28 29 modelBuilder.Entity<PharmacyHeadMedicine>() 30 .HasKey(phm => new { phm.PheadId, phm.MedicineId }); 31 modelBuilder.Entity<PharmacyHeadMedicine>() 32 .HasOne(ph => ph.Head) 33 .WithMany(m => m.PHMedicineList) 34 .HasForeignKey(k => k.PheadId); 35 36 modelBuilder.Entity<PharmacyHeadMedicine>() 37 .HasOne(m => m.Medicine) 38 .WithMany(ml => ml.MedicineList) 39 .HasForeignKey(k => k.MedicineId); 40 41 modelBuilder.Entity<PharmacyHead>() 42 .HasMany(p => p.PharmaciesList) 43 .WithOne(h => h.PHead) 44 .HasForeignKey(k => k.PheadId); 45 46 base.OnModelCreating(modelBuilder); 47 } 20 48 } 21 49 }
Note:
See TracChangeset
for help on using the changeset viewer.