38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using UTB.Eshop.Web.Models.Database.Configurations;
|
|
using UTB.Eshop.Web.Models.Entity;
|
|
using UTB.Eshop.Web.Models.Identity;
|
|
|
|
namespace UTB.Eshop.Web.Models.Database
|
|
{
|
|
public class EshopDbContext : IdentityDbContext<User, Role, int>
|
|
{
|
|
public DbSet<CarouselItem> CarouselItems { get; set; }
|
|
public DbSet<Product> Products { get; set; }
|
|
public DbSet<Order> Orders { get; set; }
|
|
public DbSet<OrderItem> OrderItems { get; set; }
|
|
|
|
public EshopDbContext(DbContextOptions options) : base(options)
|
|
{
|
|
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.ApplyConfiguration<Order>(new OrderConfiguration());
|
|
|
|
foreach (var entity in modelBuilder.Model.GetEntityTypes())
|
|
{
|
|
entity.SetTableName(entity.GetTableName().Replace("AspNet", String.Empty));
|
|
}
|
|
}
|
|
}
|
|
}
|