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 DbSet TypeStajy { get; set; } public DbSet RabotnikTypeStajy { get; set; } public DbSet Childy { get; set; } public DbSet Learny { get; set; } public DbSet CorrStajy { get; set; } public DbSet Freey { get; set; } public DbSet Accessy { get; set; } public DbSet Usery { 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 static partial class FuncDB { public static void InitDB() { if (UserGetByLogin("Admin") != null) return; var user = new User() { Login = "Admin", Pass = "Admin", Hide = true, Default = 7 }; UserAdd(user); } } }