aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/DevHiveContext.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-01-30 19:28:06 +0200
committertranstrike <transtrike@gmail.com>2021-01-30 19:28:06 +0200
commit9d5f4628a3a75871b47ac6a9f9c0419748d9dfb8 (patch)
treec738e02bb41de7c4318b7a3e273e2425a6b1635b /src/DevHive.Data/DevHiveContext.cs
parent866a5a15b8b722bc78d065f73adc0c465f264f55 (diff)
downloadDevHive-9d5f4628a3a75871b47ac6a9f9c0419748d9dfb8.tar
DevHive-9d5f4628a3a75871b47ac6a9f9c0419748d9dfb8.tar.gz
DevHive-9d5f4628a3a75871b47ac6a9f9c0419748d9dfb8.zip
User - Friend relation inital fix
Diffstat (limited to 'src/DevHive.Data/DevHiveContext.cs')
-rw-r--r--src/DevHive.Data/DevHiveContext.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/DevHive.Data/DevHiveContext.cs b/src/DevHive.Data/DevHiveContext.cs
index 7eb90de..e7c606f 100644
--- a/src/DevHive.Data/DevHiveContext.cs
+++ b/src/DevHive.Data/DevHiveContext.cs
@@ -15,6 +15,7 @@ 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)
@@ -30,10 +31,16 @@ namespace DevHive.Data
.WithMany(x => x.Users);
/* Friends */
+ builder.Entity<UserFriends>()
+ .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)
- .WithMany(x => x.Friends)
- .UsingEntity(x => x.ToTable("UserFriends"));
+ .WithOne(x => x.User);
/* Languages */
builder.Entity<User>()
@@ -66,6 +73,10 @@ namespace DevHive.Data
.HasMany(x => x.Comments)
.WithOne(x => x.Post);
+ builder.Entity<Post>()
+ .HasOne(x => x.Rating)
+ .WithOne(x => x.Post);
+
/* Comment */
builder.Entity<Comment>()
.HasOne(x => x.Post)