PIbd-21_MasenkinMS_SUBD_Rou.../RouteGuide/RouteGuideDatabaseImplement/RouteGuideDatabase.cs

65 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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; }
}
}