Skip to content

Commit

Permalink
fix the issue where a column is generated for a column that does not …
Browse files Browse the repository at this point in the history
…exist

ifd pipeline is generating a column that does not exist, because there is no foreign key relationship but we have a navigation property
  • Loading branch information
mikestock-nimble committed Dec 18, 2023
1 parent 46d3d74 commit 786da43
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 39 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
ParliamentaryConstituencycode = table.Column<string>(name: "ParliamentaryConstituency(code)", type: "nvarchar(max)", nullable: true),
PhaseOfEducationcode = table.Column<int>(name: "PhaseOfEducation(code)", type: "int", nullable: true),
SenUnitCapacity = table.Column<int>(type: "int", nullable: true),
SenUnitOnRoll = table.Column<int>(type: "int", nullable: true),
IfdPipelineSK = table.Column<long>(type: "bigint", nullable: true)
SenUnitOnRoll = table.Column<int>(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,
Expand Down Expand Up @@ -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",
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("nvarchar(max)")
.HasColumnName("HeadTitle");

b.Property<long?>("IfdPipelineSK")
.HasColumnType("bigint");

b.Property<DateTime?>("InspectionEndDate")
.HasColumnType("datetime2")
.HasColumnName("Inspection end date");
Expand Down Expand Up @@ -405,8 +402,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("EstablishmentTypeId");

b.HasIndex("IfdPipelineSK");

b.HasIndex("LocalAuthorityId");

b.ToTable("EducationEstablishment", "mstr");
Expand Down Expand Up @@ -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");
});

Expand Down
4 changes: 4 additions & 0 deletions Dfe.Academies.Api.Infrastructure/MstrContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ private void ConfigureEstablishment(EntityTypeBuilder<Establishment> 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);
}

/// <summary>
Expand Down

0 comments on commit 786da43

Please sign in to comment.