37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using FinlyticCore.Entities.Settings;
|
|
using FinlyticTechnicalAnalysis.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace FinlyticTechnicalAnalysis.Database;
|
|
|
|
public class TechnicalAnalysisDbContext : DbContext
|
|
{
|
|
public TechnicalAnalysisDbContext(DbContextOptions<TechnicalAnalysisDbContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
public DbSet<SettingEntity> DynamicSettings => Set<SettingEntity>();
|
|
public DbSet<MarketCandleEntity> MarketCandles => Set<MarketCandleEntity>();
|
|
public DbSet<MacroDataEntity> MacroData => Set<MacroDataEntity>();
|
|
public DbSet<CachedAnalysisEntity> CachedAnalyses => Set<CachedAnalysisEntity>();
|
|
public DbSet<TaSettingsEntity> Settings => Set<TaSettingsEntity>();
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.Entity<SettingEntity>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id);
|
|
entity.HasIndex(e => e.Key);
|
|
});
|
|
|
|
modelBuilder.Entity<MarketCandleEntity>()
|
|
.HasIndex(c => new { c.Symbol, c.Interval, c.Timestamp })
|
|
.IsUnique();
|
|
|
|
modelBuilder.Entity<CachedAnalysisEntity>()
|
|
.HasIndex(c => c.Isin);
|
|
}
|
|
}
|