From 4303a7fc897f742fa55a7ccb5d22816f037bf6f5 Mon Sep 17 00:00:00 2001 From: Truls Henrik Jakobsen Date: Mon, 6 Jan 2025 09:16:45 +0100 Subject: [PATCH] chore: cleanup ApplicationContext --- .../DatabaseContext/ApplicationContext.cs | 35 +++++++------------ .../ApplicationContextModelSnapshot.cs | 28 +++++++-------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/backend/Infrastructure/DatabaseContext/ApplicationContext.cs b/backend/Infrastructure/DatabaseContext/ApplicationContext.cs index c06bbb60..25b2c1b9 100644 --- a/backend/Infrastructure/DatabaseContext/ApplicationContext.cs +++ b/backend/Infrastructure/DatabaseContext/ApplicationContext.cs @@ -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 { get; set; } = null!; - public DbSet Competence { get; set; } = null!; - public DbSet CompetenceConsultant { get; set; } = null!; - public DbSet Department { get; set; } = null!; - public DbSet Organization { get; set; } = null!; - public DbSet Absence { get; set; } = null!; - - public DbSet PlannedAbsence { get; set; } = null!; - public DbSet Vacation { get; set; } = null!; - public DbSet Customer { get; set; } = null!; - public DbSet Project { get; set; } = null!; - public DbSet Staffing { get; set; } = null!; - public DbSet Agreements { get; set; } = null!; + public DbSet Consultant { get; init; } = null!; + public DbSet Competence { get; init; } = null!; + public DbSet CompetenceConsultant { get; init; } = null!; + public DbSet Department { get; init; } = null!; + public DbSet Organization { get; init; } = null!; + public DbSet Absence { get; init; } = null!; + public DbSet PlannedAbsence { get; init; } = null!; + public DbSet Vacation { get; init; } = null!; + public DbSet Customer { get; init; } = null!; + public DbSet Project { get; init; } = null!; + public DbSet Staffing { get; init; } = null!; + public DbSet Agreements { get; init; } = null!; protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) @@ -135,10 +130,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .Property(v => v.EndDate) .HasConversion(); - /*modelBuilder.Entity() - .HasMany(v => v.CompetenceConsultant) - .WithMany();*/ - modelBuilder.Entity() .Property(c => c.TransferredVacationDays) .HasDefaultValue(0); diff --git a/backend/Infrastructure/Migrations/ApplicationContextModelSnapshot.cs b/backend/Infrastructure/Migrations/ApplicationContextModelSnapshot.cs index b4fc0430..0b56970d 100644 --- a/backend/Infrastructure/Migrations/ApplicationContextModelSnapshot.cs +++ b/backend/Infrastructure/Migrations/ApplicationContextModelSnapshot.cs @@ -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 => @@ -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 => @@ -106,7 +106,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Competence"); + b.ToTable("Competence", (string)null); b.HasData( new @@ -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 => @@ -192,7 +192,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("DepartmentId"); - b.ToTable("Consultant"); + b.ToTable("Consultant", (string)null); b.HasData( new @@ -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 => @@ -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 => @@ -282,7 +282,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OrganizationId"); - b.ToTable("Department"); + b.ToTable("Department", (string)null); b.HasData( new @@ -321,7 +321,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Organization"); + b.ToTable("Organization", (string)null); b.HasData( new @@ -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 => @@ -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 => @@ -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 => @@ -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("Id") .ValueGeneratedOnAdd() @@ -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");