2024-11-18 09:39:24 +05:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-11-22 17:52:15 +05:00
|
|
|
using Npgsql;
|
|
|
|
using Persistence.Database.Entity;
|
2024-11-15 16:29:15 +05:00
|
|
|
using System.Data.Common;
|
2024-11-14 15:17:43 +05:00
|
|
|
|
|
|
|
namespace Persistence.Database.Model;
|
|
|
|
public partial class PersistenceDbContext : DbContext, IPersistenceDbContext
|
|
|
|
{
|
|
|
|
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
|
|
|
|
2024-11-18 09:39:24 +05:00
|
|
|
public DbSet<Setpoint> Setpoint => Set<Setpoint>();
|
|
|
|
|
2024-11-22 17:52:15 +05:00
|
|
|
public DbSet<TimestampedSet> TimestampedSets => Set<TimestampedSet>();
|
|
|
|
|
2024-11-15 16:29:15 +05:00
|
|
|
public PersistenceDbContext()
|
|
|
|
: base()
|
|
|
|
{
|
2024-11-22 17:52:15 +05:00
|
|
|
|
2024-11-15 16:29:15 +05:00
|
|
|
}
|
|
|
|
|
2024-11-14 15:17:43 +05:00
|
|
|
public PersistenceDbContext(DbContextOptions<PersistenceDbContext> options)
|
2024-11-15 16:29:15 +05:00
|
|
|
: base(options)
|
2024-11-14 15:17:43 +05:00
|
|
|
{
|
2024-11-15 16:29:15 +05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-11-14 15:17:43 +05:00
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
{
|
|
|
|
if (!optionsBuilder.IsConfigured)
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;Database=persistence;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True;"
|
|
|
|
//, builder=>builder.EnableRetryOnFailure(2, System.TimeSpan.FromMinutes(1))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
{
|
|
|
|
modelBuilder.HasPostgresExtension("adminpack")
|
|
|
|
.HasAnnotation("Relational:Collation", "Russian_Russia.1251");
|
2024-11-15 16:29:15 +05:00
|
|
|
|
2024-11-22 17:52:15 +05:00
|
|
|
modelBuilder.Entity<TimestampedSet>()
|
|
|
|
.Property(e => e.Set)
|
|
|
|
.HasJsonConversion();
|
|
|
|
}
|
2024-11-14 15:17:43 +05:00
|
|
|
}
|