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

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

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

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

            modelBuilder.Entity<HIST_TestListFile>()
                .HasKey(k => new { k.TestListFileNo });

            modelBuilder.Entity<HIST_TestListFileLatestStepVersion>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<HIST_TestListFileVariantList>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<PROD_Group>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<PROD_Release>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<PROD_Variant>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<STAT_Host>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<STAT_TestCode>()
                .HasKey(k => new { k.No });            

            modelBuilder.Entity<STAT_User>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<STOR_TestListFile>()
                .HasKey(k => new { k.No });

            modelBuilder.Entity<VRFY_TestListFileRelease>()
                .HasKey(k => new { k.No });        
        }

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

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

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

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

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

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

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

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

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

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

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

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