This commit is contained in:
mmrbnjd
2025-07-24 23:18:11 +03:30
parent 4977be215c
commit d4c4bb2ffd
20 changed files with 2285 additions and 65 deletions

View File

@@ -1,4 +1,5 @@
using Hushian.Domain.Entites;
using Identity.Models;
using Microsoft.EntityFrameworkCore;
@@ -7,30 +8,40 @@ namespace Hushian.Persistence
public class HushianDbContext : DbContext
{
public HushianDbContext(DbContextOptions<HushianDbContext> options)
:base(options)
: base(options)
{
}
#region Table
public DbSet<Company> Companies { get; set; }
public DbSet<Conversation> Conversations { get; set; }
public DbSet<ConversationResponse> ConversationItems { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<Exper> Expers { get; set; }
public DbSet<ExperGroup> EG { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<Conversation> Conversations { get; set; }
public DbSet<ConversationResponse> ConversationItems { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<Exper> Expers { get; set; }
public DbSet<ExperGroup> EG { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<VerificationCode > verificationCodes { get; set; }
#endregion
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ExperGroup>().HasKey(c => new { c.ExperID, c.GroupID });
modelBuilder.Entity<ExperGroup>().HasOne(eg => eg.Exper)
.WithMany(e => e.EG)
.HasForeignKey(eg => eg.ExperID)
.OnDelete(DeleteBehavior.ClientCascade);
modelBuilder.Entity<ExperGroup>()
.HasOne(eg => eg.Group)
.WithMany(g => g.EG)
.HasForeignKey(eg => eg.GroupID)
.OnDelete(DeleteBehavior.ClientCascade);
modelBuilder
.ApplyConfigurationsFromAssembly(typeof(HushianDbContext).Assembly);
}
}
}