...
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user