PIbd-22_Chernyshev_Shabunov.../ComputerShopDatabaseImplement/ComputerShopDatabase.cs
2024-05-02 00:10:15 +04:00

45 lines
1.4 KiB
C#

using ComputerShopDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace ComputerShopDatabaseImplement
{
public class ComputerShopDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder OptionsBuilder)
{
if (!OptionsBuilder.IsConfigured)
{
OptionsBuilder.UseNpgsql(@"Host=localhost;Port=5000;Database=ComputerShop;Username=postgres;Password=admin");
}
base.OnConfiguring(OptionsBuilder);
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<Assembly> Assemblies { get; set; }
public virtual DbSet<AssemblyComponent> AssemblyComponents { 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<Request> Requests { get; set; }
public virtual DbSet<Shipment> Shipments { get; set; }
public virtual DbSet<ShipmentOrder> ShipmentOrders { get; set; }
public virtual DbSet<RequestOrder> RequestOrders { get; set; }
}
}