2023-04-22 21:01:25 +04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-05-03 22:48:00 +04:00
|
|
|
|
using System.ComponentModel;
|
2023-05-04 21:53:02 +04:00
|
|
|
|
using System.Configuration;
|
2023-04-22 21:01:25 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-05-03 22:48:00 +04:00
|
|
|
|
using TransportGuideDatabaseImplements.Models;
|
2023-04-22 21:01:25 +04:00
|
|
|
|
|
|
|
|
|
namespace TransportGuideDatabaseImplements
|
|
|
|
|
{
|
|
|
|
|
public class TransportGuideDB : DbContext
|
|
|
|
|
{
|
2023-05-04 21:53:02 +04:00
|
|
|
|
string dbName = ConfigurationManager.AppSettings["connectToDb"];
|
|
|
|
|
|
2023-04-22 21:01:25 +04:00
|
|
|
|
|
2023-05-04 20:21:27 +04:00
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
|
|
|
|
if (optionsBuilder.IsConfigured == false)
|
|
|
|
|
{
|
2023-05-04 21:53:02 +04:00
|
|
|
|
optionsBuilder.UseNpgsql(dbName);
|
2023-05-04 20:21:27 +04:00
|
|
|
|
}
|
|
|
|
|
base.OnConfiguring(optionsBuilder);
|
|
|
|
|
}
|
2023-05-03 22:48:00 +04:00
|
|
|
|
public virtual DbSet<Route> Routes { set; get; }
|
|
|
|
|
public virtual DbSet<Stop> Stops { set; get; }
|
|
|
|
|
public virtual DbSet<StopRoute> StopRoutes { set; get; }
|
|
|
|
|
public virtual DbSet<TransportType> TransportTypes { set; get; }
|
|
|
|
|
}
|
2023-04-22 21:01:25 +04:00
|
|
|
|
}
|