Files
Hushian/Infrastructure/Persistence/HushianDbContext.cs
mmrbnjd 029a10e1af ....
2025-08-16 01:12:45 +03:30

49 lines
1.6 KiB
C#

using Hushian.Domain.Entites;
using Identity.Models;
using Microsoft.EntityFrameworkCore;
namespace Hushian.Persistence
{
public class HushianDbContext : DbContext
{
public HushianDbContext(DbContextOptions<HushianDbContext> 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<User> Users { get; set; }
public DbSet<VerificationCode > verificationCodes { get; set; }
public DbSet<Prompt> prompts { 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);
}
}
}