PIbd-31_MasenkinMS_COP_22/Components/DatabaseImplement/Database.cs
2024-09-23 05:00:01 +04:00

45 lines
1.4 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 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; }
}
}