Changeset 899b19d for resTools_backend/backend/Data/DataContext.cs
- Timestamp:
- 07/10/22 10:27:45 (2 years ago)
- Branches:
- master
- Children:
- a26f6a1
- Parents:
- cc4db18
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Data/DataContext.cs
rcc4db18 r899b19d 66 66 } 67 67 68 private DbSet<Review> reviews; 69 public DbSet<Review> Reviews 70 { 71 get 72 { 73 if (reviews == null) 74 { 75 reviews = Set<Review>(); 76 } 77 78 return reviews; 79 } 80 } 81 68 82 69 83 protected override void OnModelCreating(ModelBuilder modelBuilder) … … 89 103 .WithOne(b => b.Restaurant); 90 104 modelBuilder.Entity<Restaurant>() 91 .HasMany(p => p. Menu)105 .HasMany(p => p.Reviews) 92 106 .WithOne(b => b.Restaurant); 93 94 107 95 108 // … … 108 121 .HasOne(p => p.Restaurant) 109 122 .WithMany(b => b.Menu); 123 124 // 125 // Review 126 // 127 modelBuilder.Entity<Review>().Property(x => x.Id).IsRequired().ValueGeneratedOnAdd(); 128 modelBuilder.Entity<Review>() 129 .HasOne(p => p.Restaurant) 130 .WithMany(b => b.Reviews); 131 modelBuilder.Entity<Review>() 132 .HasOne(p => p.User); 110 133 } 111 134 }
Note:
See TracChangeset
for help on using the changeset viewer.