diff --git a/Dfe.Academies.Api.Infrastructure/Migrations/20231218095513_Initial.Designer.cs b/Dfe.Academies.Api.Infrastructure/Migrations/20231218104547_Initial.Designer.cs similarity index 98% rename from Dfe.Academies.Api.Infrastructure/Migrations/20231218095513_Initial.Designer.cs rename to Dfe.Academies.Api.Infrastructure/Migrations/20231218104547_Initial.Designer.cs index 0331cbe5c..056b335d1 100644 --- a/Dfe.Academies.Api.Infrastructure/Migrations/20231218095513_Initial.Designer.cs +++ b/Dfe.Academies.Api.Infrastructure/Migrations/20231218104547_Initial.Designer.cs @@ -12,7 +12,7 @@ namespace Dfe.Academies.Infrastructure.Migrations { [DbContext(typeof(MstrContext))] - [Migration("20231218095513_Initial")] + [Migration("20231218104547_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -160,9 +160,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)") .HasColumnName("HeadTitle"); - b.Property("IfdPipelineSK") - .HasColumnType("bigint"); - b.Property("InspectionEndDate") .HasColumnType("datetime2") .HasColumnName("Inspection end date"); @@ -407,8 +404,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("EstablishmentTypeId"); - b.HasIndex("IfdPipelineSK"); - b.HasIndex("LocalAuthorityId"); b.ToTable("EducationEstablishment", "mstr"); @@ -739,18 +734,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .WithMany() .HasForeignKey("EstablishmentTypeId"); - b.HasOne("Dfe.Academies.Domain.Establishment.IfdPipeline", "IfdPipeline") - .WithMany() - .HasForeignKey("IfdPipelineSK"); - b.HasOne("Dfe.Academies.Domain.Establishment.LocalAuthority", "LocalAuthority") .WithMany() .HasForeignKey("LocalAuthorityId"); b.Navigation("EstablishmentType"); - b.Navigation("IfdPipeline"); - b.Navigation("LocalAuthority"); }); diff --git a/Dfe.Academies.Api.Infrastructure/Migrations/20231218095513_Initial.cs b/Dfe.Academies.Api.Infrastructure/Migrations/20231218104547_Initial.cs similarity index 97% rename from Dfe.Academies.Api.Infrastructure/Migrations/20231218095513_Initial.cs rename to Dfe.Academies.Api.Infrastructure/Migrations/20231218104547_Initial.cs index 4898806fb..3b5572bfd 100644 --- a/Dfe.Academies.Api.Infrastructure/Migrations/20231218095513_Initial.cs +++ b/Dfe.Academies.Api.Infrastructure/Migrations/20231218104547_Initial.cs @@ -184,18 +184,11 @@ protected override void Up(MigrationBuilder migrationBuilder) ParliamentaryConstituencycode = table.Column(name: "ParliamentaryConstituency(code)", type: "nvarchar(max)", nullable: true), PhaseOfEducationcode = table.Column(name: "PhaseOfEducation(code)", type: "int", nullable: true), SenUnitCapacity = table.Column(type: "int", nullable: true), - SenUnitOnRoll = table.Column(type: "int", nullable: true), - IfdPipelineSK = table.Column(type: "bigint", nullable: true) + SenUnitOnRoll = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_EducationEstablishment", x => x.SK); - table.ForeignKey( - name: "FK_EducationEstablishment_IfdPipeline_IfdPipelineSK", - column: x => x.IfdPipelineSK, - principalSchema: "mstr", - principalTable: "IfdPipeline", - principalColumn: "SK"); table.ForeignKey( name: "FK_EducationEstablishment_Ref_EducationEstablishmentType_FK_EstablishmentType", column: x => x.FK_EstablishmentType, @@ -313,12 +306,6 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "EducationEstablishment", column: "FK_LocalAuthority"); - migrationBuilder.CreateIndex( - name: "IX_EducationEstablishment_IfdPipelineSK", - schema: "mstr", - table: "EducationEstablishment", - column: "IfdPipelineSK"); - migrationBuilder.CreateIndex( name: "IX_Trust_FK_TrustType", schema: "mstr", @@ -337,11 +324,11 @@ protected override void Down(MigrationBuilder migrationBuilder) schema: "mstr"); migrationBuilder.DropTable( - name: "Trust", + name: "IfdPipeline", schema: "mstr"); migrationBuilder.DropTable( - name: "IfdPipeline", + name: "Trust", schema: "mstr"); migrationBuilder.DropTable( diff --git a/Dfe.Academies.Api.Infrastructure/Migrations/MstrContextModelSnapshot.cs b/Dfe.Academies.Api.Infrastructure/Migrations/MstrContextModelSnapshot.cs index f969e68c6..6fd6a0097 100644 --- a/Dfe.Academies.Api.Infrastructure/Migrations/MstrContextModelSnapshot.cs +++ b/Dfe.Academies.Api.Infrastructure/Migrations/MstrContextModelSnapshot.cs @@ -158,9 +158,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)") .HasColumnName("HeadTitle"); - b.Property("IfdPipelineSK") - .HasColumnType("bigint"); - b.Property("InspectionEndDate") .HasColumnType("datetime2") .HasColumnName("Inspection end date"); @@ -405,8 +402,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("EstablishmentTypeId"); - b.HasIndex("IfdPipelineSK"); - b.HasIndex("LocalAuthorityId"); b.ToTable("EducationEstablishment", "mstr"); @@ -737,18 +732,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany() .HasForeignKey("EstablishmentTypeId"); - b.HasOne("Dfe.Academies.Domain.Establishment.IfdPipeline", "IfdPipeline") - .WithMany() - .HasForeignKey("IfdPipelineSK"); - b.HasOne("Dfe.Academies.Domain.Establishment.LocalAuthority", "LocalAuthority") .WithMany() .HasForeignKey("LocalAuthorityId"); b.Navigation("EstablishmentType"); - b.Navigation("IfdPipeline"); - b.Navigation("LocalAuthority"); }); diff --git a/Dfe.Academies.Api.Infrastructure/MstrContext.cs b/Dfe.Academies.Api.Infrastructure/MstrContext.cs index b124374e4..c5b1e7d39 100644 --- a/Dfe.Academies.Api.Infrastructure/MstrContext.cs +++ b/Dfe.Academies.Api.Infrastructure/MstrContext.cs @@ -157,6 +157,10 @@ private void ConfigureEstablishment(EntityTypeBuilder establishme .WithMany() .HasForeignKey(x => x.LocalAuthorityId) .IsRequired(false); + + // No relationship exists yet + // Make sure entity framework doesn't generate one + establishmentConfiguration.Ignore(x => x.IfdPipeline); } ///