Files
Hushian/Infrastructure/Persistence/HushianDbContext.cs

50 lines
1.7 KiB
C#
Raw Normal View History

2025-06-28 15:31:07 +03:30
using Hushian.Domain.Entites;
2025-07-24 23:18:11 +03:30
using Identity.Models;
2025-06-28 15:31:07 +03:30
using Microsoft.EntityFrameworkCore;
namespace Hushian.Persistence
{
public class HushianDbContext : DbContext
{
public HushianDbContext(DbContextOptions<HushianDbContext> options)
2025-07-24 23:18:11 +03:30
: base(options)
2025-06-28 15:31:07 +03:30
{
2025-07-24 23:18:11 +03:30
2025-06-28 15:31:07 +03:30
}
#region Table
2025-07-24 23:18:11 +03:30
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; }
2025-06-28 15:31:07 +03:30
public DbSet<User> Users { get; set; }
2025-07-24 23:18:11 +03:30
public DbSet<VerificationCode > verificationCodes { get; set; }
2025-08-16 01:12:45 +03:30
public DbSet<Prompt> prompts { get; set; }
2025-08-18 00:28:32 +03:30
public DbSet<AIA> AIAs { get; set; }
2025-06-28 15:31:07 +03:30
#endregion
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ExperGroup>().HasKey(c => new { c.ExperID, c.GroupID });
2025-07-24 23:18:11 +03:30
modelBuilder.Entity<ExperGroup>().HasOne(eg => eg.Exper)
.WithMany(e => e.EG)
.HasForeignKey(eg => eg.ExperID)
.OnDelete(DeleteBehavior.ClientCascade);
2025-06-28 15:31:07 +03:30
2025-07-24 23:18:11 +03:30
modelBuilder.Entity<ExperGroup>()
.HasOne(eg => eg.Group)
.WithMany(g => g.EG)
.HasForeignKey(eg => eg.GroupID)
.OnDelete(DeleteBehavior.ClientCascade);
2025-06-28 15:31:07 +03:30
modelBuilder
.ApplyConfigurationsFromAssembly(typeof(HushianDbContext).Assembly);
}
2025-07-24 23:18:11 +03:30
2025-06-28 15:31:07 +03:30
}
}