using LaDOSE.Entity.Challonge; using LaDOSE.Entity.Wordpress; using Microsoft.EntityFrameworkCore; namespace LaDOSE.Entity.Context { public class LaDOSEDbContext : DbContext { public DbSet Game { get; set; } public DbSet ApplicationUser { get; set; } public DbSet Todo { get; set; } #region WordPress public DbSet WPUser { get; set; } public DbSet WPEvent { get; set; } public DbSet WPBooking { get; set; } #endregion #region Tournament public DbSet Player { get; set; } public DbSet Event { get; set; } public DbSet Tournament { get; set; } public DbSet Result { get; set; } #endregion public DbSet ChallongeParticipent { get; set; } public DbSet ChallongeTournament { get; set; } public LaDOSEDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); //modelBuilder.Entity() // .HasOne(s => s.Season) // .WithMany(p => p.Event) // .HasForeignKey(fk => fk.SeasonId); //#region SeasonGame //modelBuilder.Entity() // .HasKey(t => new { t.SeasonId, t.GameId }); //modelBuilder.Entity() // .HasOne(pt => pt.Season) // .WithMany(p => p.Games) // .HasForeignKey(pt => pt.SeasonId); //modelBuilder.Entity() // .HasOne(pt => pt.Game) // .WithMany(p => p.Seasons) // .HasForeignKey(pt => pt.GameId); //#endregion //#region EventGame //modelBuilder.Entity() // .HasKey(t => new { t.EventId, t.GameId }); //modelBuilder.Entity() // .HasOne(pt => pt.Event) // .WithMany(p => p.Games) // .HasForeignKey(pt => pt.EventId); //modelBuilder.Entity() // .HasOne(pt => pt.Game) // .WithMany(p => p.Events) // .HasForeignKey(pt => pt.GameId); //#endregion #region WordPress WPBooking modelBuilder.Entity() .HasKey(t => new { t.WPEventId, t.WPUserId }); modelBuilder.Entity() .HasOne(pt => pt.WPEvent) .WithMany(p => p.WPBookings) .HasForeignKey(pt => pt.WPEventId); modelBuilder.Entity() .HasOne(pt => pt.WPUser) .WithMany(p => p.WPBookings) .HasForeignKey(pt => pt.WPUserId); #endregion #region Challonge modelBuilder.Entity() .HasOne(pt => pt.ChallongeTournament) .WithMany(p => p.Participents) .HasForeignKey(pt => pt.ChallongeTournamentId); #endregion } } }