Skip to content

Commit

Permalink
chore: cleanup ApplicationContext
Browse files Browse the repository at this point in the history
  • Loading branch information
trulshj committed Jan 6, 2025
1 parent f71bd01 commit 4303a7f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
35 changes: 13 additions & 22 deletions backend/Infrastructure/DatabaseContext/ApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@

namespace Infrastructure.DatabaseContext;

public class ApplicationContext : DbContext
public class ApplicationContext(DbContextOptions options) : DbContext(options)
{
public ApplicationContext(DbContextOptions options) : base(options)
{
}

public DbSet<Consultant?> Consultant { get; set; } = null!;
public DbSet<Competence> Competence { get; set; } = null!;
public DbSet<CompetenceConsultant> CompetenceConsultant { get; set; } = null!;
public DbSet<Department> Department { get; set; } = null!;
public DbSet<Organization> Organization { get; set; } = null!;
public DbSet<Absence> Absence { get; set; } = null!;

public DbSet<PlannedAbsence> PlannedAbsence { get; set; } = null!;
public DbSet<Vacation> Vacation { get; set; } = null!;
public DbSet<Customer> Customer { get; set; } = null!;
public DbSet<Engagement> Project { get; set; } = null!;
public DbSet<Staffing> Staffing { get; set; } = null!;
public DbSet<Agreement> Agreements { get; set; } = null!;
public DbSet<Consultant> Consultant { get; init; } = null!;
public DbSet<Competence> Competence { get; init; } = null!;
public DbSet<CompetenceConsultant> CompetenceConsultant { get; init; } = null!;
public DbSet<Department> Department { get; init; } = null!;
public DbSet<Organization> Organization { get; init; } = null!;
public DbSet<Absence> Absence { get; init; } = null!;
public DbSet<PlannedAbsence> PlannedAbsence { get; init; } = null!;
public DbSet<Vacation> Vacation { get; init; } = null!;
public DbSet<Customer> Customer { get; init; } = null!;
public DbSet<Engagement> Project { get; init; } = null!;
public DbSet<Staffing> Staffing { get; init; } = null!;
public DbSet<Agreement> Agreements { get; init; } = null!;


protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
Expand Down Expand Up @@ -135,10 +130,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Property(v => v.EndDate)
.HasConversion<DateOnlyConverter>();

/*modelBuilder.Entity<Consultant>()
.HasMany(v => v.CompetenceConsultant)
.WithMany();*/

modelBuilder.Entity<Consultant>()
.Property(c => c.TransferredVacationDays)
.HasDefaultValue(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("OrganizationId");

b.ToTable("Absence");
b.ToTable("Absence", (string)null);
});

modelBuilder.Entity("Core.Agreements.Agreement", b =>
Expand Down Expand Up @@ -92,7 +92,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("EngagementId");

b.ToTable("Agreements");
b.ToTable("Agreements", (string)null);
});

modelBuilder.Entity("Core.Consultants.Competence", b =>
Expand All @@ -106,7 +106,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasKey("Id");

b.ToTable("Competence");
b.ToTable("Competence", (string)null);

b.HasData(
new
Expand Down Expand Up @@ -148,7 +148,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("CompetencesId");

b.ToTable("CompetenceConsultant");
b.ToTable("CompetenceConsultant", (string)null);
});

modelBuilder.Entity("Core.Consultants.Consultant", b =>
Expand Down Expand Up @@ -192,7 +192,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("DepartmentId");

b.ToTable("Consultant");
b.ToTable("Consultant", (string)null);

b.HasData(
new
Expand Down Expand Up @@ -228,7 +228,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("OrganizationId", "Name")
.IsUnique();

b.ToTable("Customer");
b.ToTable("Customer", (string)null);
});

modelBuilder.Entity("Core.Engagements.Engagement", b =>
Expand Down Expand Up @@ -258,7 +258,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("CustomerId", "Name")
.IsUnique();

b.ToTable("Project");
b.ToTable("Project", (string)null);
});

modelBuilder.Entity("Core.Organizations.Department", b =>
Expand All @@ -282,7 +282,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("OrganizationId");

b.ToTable("Department");
b.ToTable("Department", (string)null);

b.HasData(
new
Expand Down Expand Up @@ -321,7 +321,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasKey("Id");

b.ToTable("Organization");
b.ToTable("Organization", (string)null);

b.HasData(
new
Expand Down Expand Up @@ -354,7 +354,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("ConsultantId");

b.ToTable("PlannedAbsence");
b.ToTable("PlannedAbsence", (string)null);
});

modelBuilder.Entity("Core.Staffings.Staffing", b =>
Expand All @@ -375,7 +375,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("ConsultantId");

b.ToTable("Staffing");
b.ToTable("Staffing", (string)null);
});

modelBuilder.Entity("Core.Vacations.Vacation", b =>
Expand All @@ -396,7 +396,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("ConsultantId");

b.ToTable("Vacation");
b.ToTable("Vacation", (string)null);
});

modelBuilder.Entity("Core.Absences.Absence", b =>
Expand All @@ -422,7 +422,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasForeignKey("EngagementId")
.OnDelete(DeleteBehavior.Restrict);

b.OwnsMany("Core.Agreements.FileReference", "Files", b1 =>
b.OwnsMany("Core.Agreements.Agreement.Files#Core.Agreements.FileReference", "Files", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
Expand Down Expand Up @@ -451,7 +451,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b1.HasIndex("AgreementId");

b1.ToTable("FileReference");
b1.ToTable("FileReference", (string)null);

b1.WithOwner()
.HasForeignKey("AgreementId");
Expand Down

0 comments on commit 4303a7f

Please sign in to comment.