aboutsummaryrefslogtreecommitdiff
path: root/src/Data/DevHive.Data/DevHiveContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/DevHive.Data/DevHiveContext.cs')
-rw-r--r--src/Data/DevHive.Data/DevHiveContext.cs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Data/DevHive.Data/DevHiveContext.cs b/src/Data/DevHive.Data/DevHiveContext.cs
index 621336f..0606864 100644
--- a/src/Data/DevHive.Data/DevHiveContext.cs
+++ b/src/Data/DevHive.Data/DevHiveContext.cs
@@ -17,6 +17,7 @@ namespace DevHive.Data
public DbSet<PostAttachments> PostAttachments { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<Rating> Rating { get; set; }
+ public DbSet<ProfilePicture> ProfilePicture { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
@@ -25,11 +26,6 @@ namespace DevHive.Data
.HasIndex(x => x.UserName)
.IsUnique();
- builder.Entity<User>()
- .HasOne(x => x.ProfilePicture)
- .WithOne(x => x.User)
- .HasForeignKey<ProfilePicture>(x => x.UserId);
-
/* Roles */
builder.Entity<User>()
.HasMany(x => x.Roles)
@@ -92,6 +88,15 @@ namespace DevHive.Data
.HasMany(x => x.Ratings)
.WithOne(x => x.Post);
+ /* Profile Picture */
+ builder.Entity<ProfilePicture>()
+ .HasKey(x => x.Id);
+
+ builder.Entity<User>()
+ .HasOne(x => x.ProfilePicture)
+ .WithOne(x => x.User)
+ .HasForeignKey<ProfilePicture>(x => x.UserId);
+
base.OnModelCreating(builder);
}
}