28 lines
905 B
C#
28 lines
905 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
|
|
namespace Hcs.WebApp.Data.Hcs
|
|
{
|
|
public class HcsDbContext(DbContextOptions<HcsDbContext> options) : DbContext(options)
|
|
{
|
|
public DbSet<Registry> Registries { get; set; }
|
|
|
|
public DbSet<RegistryElement> Elements { get; set; }
|
|
|
|
public DbSet<Campaign> Campaigns { get; set; }
|
|
|
|
public DbSet<Operation> Operations { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Campaign>()
|
|
.Property(x => x.Type)
|
|
.HasConversion(new EnumToStringConverter<Campaign.CampaignType>());
|
|
|
|
modelBuilder.Entity<Operation>()
|
|
.Property(x => x.Type)
|
|
.HasConversion(new EnumToStringConverter<Operation.OperationType>());
|
|
}
|
|
}
|
|
}
|