aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/DevHiveContext.cs
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-02-05 16:36:47 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-02-05 16:36:47 +0200
commit60ed435203f0c60d4c6fabe77aa4e87656aaf8c1 (patch)
treef20f5a64142612a5da582afee039b5d0f650776f /src/DevHive.Data/DevHiveContext.cs
parenta82c21a79772217fd22e4b9e2b36a655804186c8 (diff)
downloadDevHive-60ed435203f0c60d4c6fabe77aa4e87656aaf8c1.tar
DevHive-60ed435203f0c60d4c6fabe77aa4e87656aaf8c1.tar.gz
DevHive-60ed435203f0c60d4c6fabe77aa4e87656aaf8c1.zip
Adding some metods to Rate repo
Diffstat (limited to 'src/DevHive.Data/DevHiveContext.cs')
-rw-r--r--src/DevHive.Data/DevHiveContext.cs33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/DevHive.Data/DevHiveContext.cs b/src/DevHive.Data/DevHiveContext.cs
index b3ebd73..0cc28bb 100644
--- a/src/DevHive.Data/DevHiveContext.cs
+++ b/src/DevHive.Data/DevHiveContext.cs
@@ -95,31 +95,28 @@ namespace DevHive.Data
builder.Entity<Rating>()
.HasKey(x => x.Id);
- // builder.Entity<Rating>()
- // .HasOne(x => x.Post)
- // .WithOne(x => x.Rating)
- // .HasForeignKey<Post>(x => x.RatingId);
-
- // builder.Entity<Post>()
- // .HasOne(x => x.Rating)
- // .WithOne(x => x.Post);
+ builder.Entity<Rating>()
+ .HasOne(x => x.Post)
+ .WithOne(x => x.Rating)
+ .HasForeignKey<Rating>(x => x.PostId);
- // builder.Entity<Rating>()
- // .HasMany(x => x.UsersThatRated);
+ builder.Entity<Post>()
+ .HasOne(x => x.Rating)
+ .WithOne(x => x.Post);
- // /* User Rated Posts */
+ /* User Rated Posts */
builder.Entity<RatedPost>()
.HasKey(x => new { x.UserId, x.PostId });
- // builder.Entity<RatedPost>()
- // .HasOne(x => x.User)
- // .WithMany(x => x.RatedPosts);
+ builder.Entity<RatedPost>()
+ .HasOne(x => x.User)
+ .WithMany(x => x.RatedPosts);
- // builder.Entity<RatedPost>()
- // .HasOne(x => x.Post);
+ builder.Entity<RatedPost>()
+ .HasOne(x => x.Post);
- // builder.Entity<User>()
- // .HasMany(x => x.RatedPosts);
+ builder.Entity<User>()
+ .HasMany(x => x.RatedPosts);
base.OnModelCreating(builder);
}