45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using DatabaseImplement.Models;
|
||
using Microsoft.EntityFrameworkCore;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace DatabaseImplement
|
||
{
|
||
/// <summary>
|
||
/// Класс для взаимодействия с базой данных
|
||
/// </summary>
|
||
public class Database : DbContext
|
||
{
|
||
/// <summary>
|
||
/// Параметры подключения к базе данных
|
||
/// </summary>
|
||
private string _dbConnectionString = "Host=localhost;Port=5432;Database=COPLabWorks;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<Order> Orders { get; set; }
|
||
|
||
/// <summary>
|
||
/// Таблица "Типы заказов"
|
||
/// </summary>
|
||
public virtual DbSet<OrderType> OrderTypes { get; set; }
|
||
}
|
||
}
|