65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using Microsoft.EntityFrameworkCore;
|
||
using RouteGuideDatabaseImplement.Models;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace RouteGuideDatabaseImplement
|
||
{
|
||
/// <summary>
|
||
/// Класс для взаимодействия с базой данных
|
||
/// </summary>
|
||
public class RouteGuideDatabase : DbContext
|
||
{
|
||
/// <summary>
|
||
/// Параметры подключения к базе данных
|
||
/// </summary>
|
||
private string _dbConnectionString = "Host=192.168.0.108;Port=5432;Database=RouteGuide;Username=postgres;Password=2004";
|
||
|
||
/// <summary>
|
||
/// Подключение к базе данных
|
||
/// </summary>
|
||
/// <param name="optionsBuilder"></param>
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||
{
|
||
if (optionsBuilder.IsConfigured == false)
|
||
{
|
||
optionsBuilder.UseNpgsql(_dbConnectionString);
|
||
}
|
||
base.OnConfiguring(optionsBuilder);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Таблица "Водители"
|
||
/// </summary>
|
||
public virtual DbSet<Driver> Drivers { get; set; }
|
||
|
||
/// <summary>
|
||
/// Таблица "Транспорт"
|
||
/// </summary>
|
||
public virtual DbSet<Transport> Transport { get; set; }
|
||
|
||
/// <summary>
|
||
/// Таблица "Маршруты"
|
||
/// </summary>
|
||
public virtual DbSet<Route> Routes { get; set; }
|
||
|
||
/// <summary>
|
||
/// Таблица "Остановки"
|
||
/// </summary>
|
||
public virtual DbSet<Stop> Stops { get; set; }
|
||
|
||
/// <summary>
|
||
/// Связь для сущностей "Маршруты" и "Остановки"
|
||
/// </summary>
|
||
public virtual DbSet<RouteStop> RouteStops { get; set; }
|
||
|
||
/// <summary>
|
||
/// Таблица "Расписания"
|
||
/// </summary>
|
||
public virtual DbSet<Schedule> Schedules { get; set; }
|
||
}
|
||
}
|