using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; namespace Diplom_O.DataBase { public class MainDB : DbContext { public DbSet Shtat { get; set; } public DbSet Rabotniky { get; set; } public DbSet Chely { get; set; } public MainDB() { Database.EnsureCreated(); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlite("Data Source=" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Diplom_O.db;"); } protected override void OnModelCreating(ModelBuilder modelBuilder) { } } public class Rabotnik { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [ForeignKey("Chel")] public int ChelId { get; set; } public Chel Chel { get; set; } [ForeignKey("Shtat")] public int ShtatId { get; set; } public Shtat Shtat { get; set; } public string KodSotr { get; set; } public string Kategoriya { get; set; } public bool Pensiya { get; set; } public DateTime Start { get; set; } public DateTime? End { get; set; } } public class Shtat { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Doljnost { get; set; } public int Size { get; set; } public bool Active { get; set; } } public class Chel { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string FName { get; set; } public string SName { get; set; } public string TName { get; set; } public bool Male { get; set; } public DateTime Birthday { get; set; } public string Address { get; set; } public string INN { get; set; } public string SNILS { get; set; } public string Pasport { get; set; } public List Rabota { get; set; } } }