PIbd-42_Kashin_M.I_CPO_Cour.../EmployeeManagmentDataBaseImplement/EmployeeManagementDbContext .cs

25 lines
946 B
C#

using EmployeeManagmentDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace EmployeeManagmentDataBaseImplement
{
public class EmployeeManagementDbContext : DbContext
{
// DbSets для моделей
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<PhisicalPerson> PhysicalPersons { get; set; }
public virtual DbSet<Salary> Salaries { get; set; }
public virtual DbSet<Vacation> Vacations { get; set; }
// Метод для настройки конфигурации
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseMySQL("Server=localhost;Port=3306;Database=EmployeeDB;User=root;Password=SuperSecretPasswork2003;");
}
base.OnConfiguring(optionsBuilder);
}
}
}