using Microsoft.EntityFrameworkCore; namespace LaDOSE.Entity.Context { public class LaDOSEDbContext : DbContext { public DbSet Game { get; set; } public DbSet ApplicationUser { get; set; } public DbSet Season { get; set; } public DbSet Event { get; set; } //public DbSet SeasonGame { get; set; } public LaDOSEDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasKey(t => new { t.SeasonId, t.GameId }); modelBuilder.Entity() .HasOne(s => s.Season) .WithMany(p => p.Event) .HasForeignKey(fk => fk.SeasonId); 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); } } }