aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/DevHiveContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Data/DevHiveContext.cs')
-rw-r--r--src/DevHive.Data/DevHiveContext.cs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/DevHive.Data/DevHiveContext.cs b/src/DevHive.Data/DevHiveContext.cs
index e391882..e7c606f 100644
--- a/src/DevHive.Data/DevHiveContext.cs
+++ b/src/DevHive.Data/DevHiveContext.cs
@@ -15,6 +15,8 @@ namespace DevHive.Data
public DbSet<Language> Languages { get; set; }
public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
+ public DbSet<UserFriends> UserFriends { get; set; }
+ public DbSet<Rating> Rating { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
@@ -29,9 +31,16 @@ namespace DevHive.Data
.WithMany(x => x.Users);
/* Friends */
- //TODO: Look into the User - User
builder.Entity<UserFriends>()
- .HasKey(uu => new { uu.UserId, uu.FriendId });
+ .HasKey(x => new { x.UserId, x.FriendId });
+
+ // builder.Entity<UserFriends>()
+ // .HasOne(x => x.Friend)
+ // .WithMany(x => x.Friends);
+
+ builder.Entity<User>()
+ .HasMany(x => x.Friends)
+ .WithOne(x => x.User);
/* Languages */
builder.Entity<User>()
@@ -45,9 +54,6 @@ namespace DevHive.Data
.UsingEntity(x => x.ToTable("LanguageUser"));
/* Technologies */
- builder.Entity<Technology>()
- .HasKey(x => x.Id);
-
builder.Entity<User>()
.HasMany(x => x.Technologies)
.WithMany(x => x.Users)
@@ -60,12 +66,16 @@ namespace DevHive.Data
/* Post */
builder.Entity<Post>()
+ .HasOne(x => x.Creator)
+ .WithMany(x => x.Posts);
+
+ builder.Entity<Post>()
.HasMany(x => x.Comments)
.WithOne(x => x.Post);
builder.Entity<Post>()
- .HasOne(x => x.Creator)
- .WithMany(x => x.Posts);
+ .HasOne(x => x.Rating)
+ .WithOne(x => x.Post);
/* Comment */
builder.Entity<Comment>()