mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-22 09:17:47 +00:00
34 lines
1003 B
C#
34 lines
1003 B
C#
using System.Linq;
|
|
using LiveGameFeed.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
|
|
namespace LiveGameFeed.Data
|
|
{
|
|
public class LiveGameContext : DbContext
|
|
{
|
|
public DbSet<Match> Matches { get; set; }
|
|
public DbSet<Feed> 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<Match>()
|
|
.ToTable("Match");
|
|
|
|
modelBuilder.Entity<Feed>()
|
|
.ToTable("Feed");
|
|
|
|
modelBuilder.Entity<Feed>()
|
|
.Property(f => f.MatchId)
|
|
.IsRequired();
|
|
}
|
|
}
|
|
}
|