using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using LiveGameFeed.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; namespace LiveGameFeed.Data { public class LiveGameContext : DbContext { public DbSet Matches { get; set; } public DbSet Feeds { get; set; } public LiveGameContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys())) { relationship.DeleteBehavior = DeleteBehavior.Restrict; } modelBuilder.Entity() .ToTable("Match"); modelBuilder.Entity() .ToTable("Feed"); modelBuilder.Entity() .Property(f => f.MatchId) .IsRequired(); } } }