PIbd-23_Tikhonenkov_A_E_Cou.../DiningRoom/DiningRoomDatabaseImplement/DiningRoomDatabase.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2024-04-30 00:05:31 +04:00
using DiningRoomDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace DiningRoomDatabaseImplement
{
public class DiningRoomDatabase : DbContext
{
2024-04-30 21:09:57 +04:00
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2024-04-30 00:05:31 +04:00
{
2024-04-30 21:09:57 +04:00
if (optionsBuilder.IsConfigured == false)
2024-04-30 00:05:31 +04:00
{
2024-04-30 21:09:57 +04:00
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=DiningRoomDatabase;Username=postgres;Password=postgres");
2024-04-30 00:05:31 +04:00
}
2024-04-30 21:09:57 +04:00
base.OnConfiguring(optionsBuilder);
2024-04-30 00:05:31 +04:00
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Component> Components { get; set; }
public virtual DbSet<Drink> Drinks { get; set; }
public virtual DbSet<DrinkComponent> DrinkComponents { get; set; }
public virtual DbSet<Product> Products { get; set; }
public virtual DbSet<ProductComponent> ProductComponents { get; set; }
public virtual DbSet<Order> Orders { get; set; }
public virtual DbSet<Card> Cards { get; set; }
}
}