AsbCloudDbContext Add active reference count prop

This commit is contained in:
ngfrolov 2022-12-02 10:58:19 +05:00
parent 06fe0e09ff
commit c6a1c4dae6

View File

@ -60,20 +60,32 @@ namespace AsbCloudDb.Model
public DbSet<WITS.Record50> Record50 => Set<WITS.Record50>();
public DbSet<WITS.Record60> Record60 => Set<WITS.Record60>();
public DbSet<WITS.Record61> Record61 => Set<WITS.Record61>();
public int ReferenceCount { get; private set; }
public AsbCloudDbContext() : base()
{
ReferenceCount++;
}
public AsbCloudDbContext(DbContextOptions<AsbCloudDbContext> options)
: base(options)
{
ReferenceCount++;
}
~AsbCloudDbContext()
{
ReferenceCount--;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True");
optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True"
//, builder=>builder.EnableRetryOnFailure(2, System.TimeSpan.FromMinutes(1))
);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)