hrms-api-backend/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs

61 lines
2.2 KiB
C#

using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Organizations.Report2;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Domain.Models.Probation;
using BMA.EHR.Domain.Models.Retirement;
using BMA.EHR.Domain.ModelsExam.Candidate;
using Microsoft.EntityFrameworkCore;
using System.Reflection.Emit;
namespace BMA.EHR.Infrastructure.Persistence
{
public class ApplicationDBExamContext : DbContext, IApplicationDBExamContext
{
#region " From Existing Database "
public DbSet<Candidate> Candidates { get; set; }
public DbSet<Career> Careers { get; set; }
public DbSet<Education> Educations { get; set; }
public DbSet<PeriodExam> PeriodExams { get; set; }
public DbSet<PositionExam> PositionExams { get; set; }
public DbSet<Document> Documents { get; set; }
#endregion
public ApplicationDBExamContext(DbContextOptions<ApplicationDBExamContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// exam service
modelBuilder.Entity<Candidate>().Metadata.SetIsTableExcludedFromMigrations(true);
modelBuilder.Entity<Career>().Metadata.SetIsTableExcludedFromMigrations(true);
modelBuilder.Entity<Education>().Metadata.SetIsTableExcludedFromMigrations(true);
modelBuilder.Entity<PeriodExam>().Metadata.SetIsTableExcludedFromMigrations(true);
modelBuilder.Entity<PositionExam>().Metadata.SetIsTableExcludedFromMigrations(true);
modelBuilder.Entity<Document>().Metadata.SetIsTableExcludedFromMigrations(true);
}
public Task<int> SaveChangesAsync()
{
return base.SaveChangesAsync();
}
public void Attatch<T>(T entity) where T : class
{
Attach(entity);
}
}
}