Changeset cc4db18 for resTools_backend/backend/Data
- Timestamp:
- 07/06/22 13:13:35 (2 years ago)
- Branches:
- master
- Children:
- 899b19d
- Parents:
- d76b7ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Data/DataContext.cs
rd76b7ee rcc4db18 52 52 } 53 53 54 private DbSet<MenuItem> menuItems; 55 public DbSet<MenuItem> MenuItems 56 { 57 get 58 { 59 if (menuItems == null) 60 { 61 menuItems = Set<MenuItem>(); 62 } 63 64 return menuItems; 65 } 66 } 67 54 68 55 69 protected override void OnModelCreating(ModelBuilder modelBuilder) … … 74 88 .HasMany(p => p.Reservations) 75 89 .WithOne(b => b.Restaurant); 90 modelBuilder.Entity<Restaurant>() 91 .HasMany(p => p.Menu) 92 .WithOne(b => b.Restaurant); 93 76 94 77 95 // … … 82 100 .HasOne(p => p.Restaurant) 83 101 .WithMany(b => b.Reservations); 102 103 // 104 // MenuItem 105 // 106 modelBuilder.Entity<MenuItem>().Property(x => x.Id).IsRequired().ValueGeneratedOnAdd(); 107 modelBuilder.Entity<MenuItem>() 108 .HasOne(p => p.Restaurant) 109 .WithMany(b => b.Menu); 84 110 } 85 111 }
Note:
See TracChangeset
for help on using the changeset viewer.