using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SystemX.Net.Platform.SystemX.Net.XEFCore.DBContext.CPXV2Log.Tables;

namespace SystemX.Net.Platform.SystemX.Net.XEFCore.DBContext.CPXV2Log
{
    public class CPXV2Log : DbContext
    {
        public string SqlServerConnectionString { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {            
            optionsBuilder.UseSqlServer(SqlServerConnectionString);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<HIST_LatestAccessKey>()
                .HasKey(k => new { k.KeyValue });

            modelBuilder.Entity<HIST_LogSummary>()
                .HasNoKey();

            modelBuilder.Entity<HIST_TestResult>()
                .HasNoKey();
        }

        public DbSet<HIST_LatestAccessKey> HIST_LatestAccessKey { get; set; }

        public DbSet<HIST_LogSummary> HIST_LogSummary { get; set; }

        public DbSet<HIST_TestResult> HIST_TestResult { get; set; }
    }
}
