50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using ManagerService.Data.SubSection;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ManagerService.Data
|
|
{
|
|
public class MyInfoMateDbContext : DbContext
|
|
{
|
|
public MyInfoMateDbContext(DbContextOptions<MyInfoMateDbContext> options) : base(options) { }
|
|
|
|
public DbSet<Instance> Instances { get; set; }
|
|
public DbSet<Configuration> Configurations { get; set; }
|
|
public DbSet<Section> Sections { get; set; }
|
|
public DbSet<Device> Devices { get; set; }
|
|
public DbSet<Resource> Resources { get; set; }
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
modelBuilder.Entity<Configuration>()
|
|
.Property(s => s.Title)
|
|
.HasColumnType("jsonb");
|
|
|
|
modelBuilder.Entity<Section>()
|
|
.HasDiscriminator<string>("Discriminator")
|
|
.HasValue<Section>("Base")
|
|
.HasValue<SectionAgenda>("Agenda")
|
|
.HasValue<SectionArticle>("Article")
|
|
.HasValue<SectionMap>("Map")
|
|
.HasValue<SectionMenu>("Menu")
|
|
.HasValue<SectionPdf>("PDF")
|
|
.HasValue<SectionPuzzle>("Puzzle")
|
|
.HasValue<SectionQuiz>("Quiz")
|
|
.HasValue<SectionSlider>("Slider")
|
|
.HasValue<SectionVideo>("Video")
|
|
.HasValue<SectionWeather>("Weather")
|
|
.HasValue<SectionWeb>("Web");
|
|
|
|
modelBuilder.Entity<Section>()
|
|
.Property(s => s.Title)
|
|
.HasColumnType("jsonb");
|
|
|
|
modelBuilder.Entity<Section>()
|
|
.Property(s => s.Description)
|
|
.HasColumnType("jsonb");
|
|
|
|
}
|
|
}
|
|
}
|