[30a465f] | 1 | using FarmatikoData.Models;
|
---|
| 2 | using Microsoft.EntityFrameworkCore;
|
---|
| 3 |
|
---|
| 4 | namespace FarmatikoData
|
---|
| 5 | {
|
---|
| 6 | public class FarmatikoDataContext : DbContext
|
---|
| 7 | {
|
---|
| 8 | public FarmatikoDataContext(DbContextOptions options) : base(options) { }
|
---|
[8e74e2f] | 9 |
|
---|
[30a465f] | 10 |
|
---|
[db484c9] | 11 | public DbSet<HealthFacility> HealthFacilities { get; set; }
|
---|
| 12 | public DbSet<HealthcareWorker> HealthcareWorkers { get; set; }
|
---|
| 13 | public DbSet<Pharmacy> Pharmacies { get; set; }
|
---|
| 14 | public DbSet<PharmacyHead> PharmacyHeads { get; set; }
|
---|
| 15 | public DbSet<Pandemic> Pandemics { get; set; }
|
---|
| 16 | public DbSet<Medicine> Medicines { get; set; }
|
---|
| 17 | public DbSet<RequestPharmacyHead> PHRequests { get; set; }
|
---|
| 18 | public DbSet<User> Users { get; set; }
|
---|
| 19 | public DbSet<PharmacyHeadMedicine> PharmacyHeadMedicines { get; set; }
|
---|
[8e74e2f] | 20 |
|
---|
[1db5673] | 21 | protected override void OnModelCreating(ModelBuilder modelBuilder)
|
---|
| 22 | {
|
---|
[8e74e2f] | 23 | modelBuilder.UseSerialColumns();
|
---|
| 24 |
|
---|
[1db5673] | 25 | modelBuilder.Entity<PharmacyHead>()
|
---|
| 26 | .ToTable("PharmacyHeads");
|
---|
| 27 |
|
---|
| 28 | modelBuilder.Entity<Medicine>()
|
---|
| 29 | .ToTable("Medicines");
|
---|
| 30 |
|
---|
[68454c6] | 31 | modelBuilder.Entity<Pharmacy>()
|
---|
| 32 | .ToTable("Pharmacies");
|
---|
| 33 |
|
---|
[db484c9] | 34 | modelBuilder.Entity<PharmacyHeadMedicine>()
|
---|
| 35 | .ToTable("PharmacyHeadMedicines");
|
---|
| 36 |
|
---|
| 37 | modelBuilder.Entity<RequestPharmacyHead>()
|
---|
| 38 | .ToTable("PHRequests");
|
---|
| 39 |
|
---|
[7d80751] | 40 | /*modelBuilder.Entity<Medicine>()
|
---|
[8e74e2f] | 41 | .Property(x => x.Id)
|
---|
| 42 | .HasIdentityOptions(startValue: 1);
|
---|
| 43 |
|
---|
| 44 | modelBuilder.Entity<Pharmacy>()
|
---|
| 45 | .Property(x => x.Id)
|
---|
| 46 | .HasIdentityOptions(startValue: 1);
|
---|
| 47 |
|
---|
| 48 | modelBuilder.Entity<PharmacyHead>()
|
---|
| 49 | .Property(x => x.Id)
|
---|
| 50 | .HasIdentityOptions(startValue: 1);
|
---|
| 51 |
|
---|
| 52 | modelBuilder.Entity<PharmacyHeadMedicine>()
|
---|
| 53 | .Property(x => x.Id)
|
---|
| 54 | .HasIdentityOptions(startValue: 1);
|
---|
| 55 |
|
---|
| 56 | modelBuilder.Entity<RequestPharmacyHead>()
|
---|
| 57 | .Property(x => x.Id)
|
---|
[7d80751] | 58 | .HasIdentityOptions(startValue: 1);*/
|
---|
[8e74e2f] | 59 |
|
---|
[db484c9] | 60 | /*modelBuilder.Entity<User>()
|
---|
[8e74e2f] | 61 | .Property(x => x.Id)
|
---|
| 62 | .HasIdentityOptions(startValue: 1);
|
---|
| 63 |
|
---|
[1db5673] | 64 | modelBuilder.Entity<PharmacyHeadMedicine>()
|
---|
| 65 | .HasKey(phm => new { phm.PheadId, phm.MedicineId });
|
---|
| 66 |
|
---|
| 67 | modelBuilder.Entity<PharmacyHead>()
|
---|
[db484c9] | 68 | .HasMany<Pharmacy>(p => p.Pharmacy)
|
---|
| 69 | .WithOne(p => p.PharmacyHead)
|
---|
| 70 | .HasForeignKey();
|
---|
[68454c6] | 71 |
|
---|
[db484c9] | 72 | modelBuilder.Entity<Pharmacy>()
|
---|
| 73 | .HasOne<PharmacyHead>(p => p.PharmacyHead)
|
---|
| 74 | .WithMany(p => p.Pharmacy);
|
---|
| 75 | */
|
---|
| 76 |
|
---|
[1db5673] | 77 | base.OnModelCreating(modelBuilder);
|
---|
| 78 | }
|
---|
[30a465f] | 79 | }
|
---|
| 80 | }
|
---|