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