CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs

26 lines
974 B
C#
Raw Normal View History

2024-04-29 00:44:49 +04:00
using ElectronicsShopDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
2024-04-28 23:08:09 +04:00
using System.Collections.Generic;
namespace ElectronicsShopDataBaseImplement
{
2024-04-29 00:44:49 +04:00
public class Database : DbContext
2024-04-28 23:08:09 +04:00
{
2024-04-29 00:44:49 +04:00
protected override void OnConfiguring(DbContextOptionsBuilder
optionsBuilder)
2024-04-28 23:08:09 +04:00
{
2024-04-29 00:44:49 +04:00
if (optionsBuilder.IsConfigured == false)
2024-04-28 23:08:09 +04:00
{
2024-04-29 00:44:49 +04:00
optionsBuilder.UseSqlServer(@"Data Source=.\SQLEXPRESS;Initial Catalog=ZooDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
2024-04-28 23:08:09 +04:00
}
2024-04-29 00:44:49 +04:00
base.OnConfiguring(optionsBuilder);
2024-04-28 23:08:09 +04:00
}
2024-04-29 00:44:49 +04:00
public virtual DbSet<CategoryProduct> CategoryProducts { set; get; }
public virtual DbSet<User> Users { set; get; }
public virtual DbSet<Route> Routes { set; get; }
public virtual DbSet<RoutePreserve> RoutePreserves { set; get; }
public virtual DbSet<Preserve> Preserves { set; get; }
2024-04-28 23:08:09 +04:00
}
}