persistence/DD.Persistence.Database/PersistenceDbContext.cs
Olga Nemt d90b72b14e 1. Исправлены namespaces.
2. Добавлен проект DD.Persistence.App со всеми необходимыми настройками
2024-12-16 15:38:46 +05:00

43 lines
1.2 KiB
C#

using Microsoft.EntityFrameworkCore;
using DD.Persistence.Database.Entity;
using DD.Persistence.Database.Model;
namespace DD.Persistence.Database;
/// <summary>
/// EF контекст для любых БД поддерживаемых в EF
/// </summary>
public class PersistenceDbContext : DbContext
{
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
public DbSet<Setpoint> Setpoint => Set<Setpoint>();
public DbSet<TimestampedSet> TimestampedSets => Set<TimestampedSet>();
public DbSet<ChangeLog> ChangeLog => Set<ChangeLog>();
public DbSet<TechMessage> TechMessage => Set<TechMessage>();
public DbSet<ParameterData> ParameterData => Set<ParameterData>();
public DbSet<DataSourceSystem> DataSourceSystem => Set<DataSourceSystem>();
public PersistenceDbContext(DbContextOptions options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<TimestampedSet>()
.Property(e => e.Set)
.HasJsonConversion();
modelBuilder.Entity<ChangeLog>()
.Property(e => e.Value)
.HasJsonConversion();
}
}