SUBD_SportCompetitions/SportCompetitionsDatabaseImplement/SportCompetitionsDatabase.cs

32 lines
1.0 KiB
C#

using Microsoft.EntityFrameworkCore;
using SportCompetitionsDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SportCompetitionsDatabaseImplement
{
public class SportCompetitionsDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Host=localhost;Database=SportCompetitionsDatabase;Username=postgres;Password=postgres");
}
base.OnConfiguring(optionsBuilder);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
public virtual DbSet<Competition> Competitions { get; set; }
public virtual DbSet<Member> Members { get; set; }
public virtual DbSet<Record> Records { get; set; }
public virtual DbSet<Result> Results { get; set; }
public virtual DbSet<Team> Teams { get; set; }
}
}