forked from ddrilling/AsbCloudServer
AsbCloudDbContext Add active reference count prop
This commit is contained in:
parent
06fe0e09ff
commit
c6a1c4dae6
@ -61,19 +61,31 @@ namespace AsbCloudDb.Model
|
|||||||
public DbSet<WITS.Record60> Record60 => Set<WITS.Record60>();
|
public DbSet<WITS.Record60> Record60 => Set<WITS.Record60>();
|
||||||
public DbSet<WITS.Record61> Record61 => Set<WITS.Record61>();
|
public DbSet<WITS.Record61> Record61 => Set<WITS.Record61>();
|
||||||
|
|
||||||
|
public int ReferenceCount { get; private set; }
|
||||||
|
|
||||||
public AsbCloudDbContext() : base()
|
public AsbCloudDbContext() : base()
|
||||||
{
|
{
|
||||||
|
ReferenceCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsbCloudDbContext(DbContextOptions<AsbCloudDbContext> options)
|
public AsbCloudDbContext(DbContextOptions<AsbCloudDbContext> options)
|
||||||
: base(options)
|
: base(options)
|
||||||
{
|
{
|
||||||
|
ReferenceCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
~AsbCloudDbContext()
|
||||||
|
{
|
||||||
|
ReferenceCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!optionsBuilder.IsConfigured)
|
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)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
Loading…
Reference in New Issue
Block a user