47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
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_B.DB
|
|
{
|
|
public class MainDB : DbContext
|
|
{
|
|
public DbSet<Zakazchik> Zakazchiki { get; set; }
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
public MainDB() { Database.EnsureCreated(); }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseSqlite("Data Source=" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Diplom_B.db;");
|
|
}
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder) { }
|
|
|
|
}
|
|
|
|
public class User
|
|
{
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string Pass { get; set; }
|
|
}
|
|
|
|
public class Zakazchik
|
|
{
|
|
[Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string Adres { get; set; }
|
|
public string Phone { get; set; }
|
|
}
|
|
|
|
|
|
}
|