Skip to content

Commit 596dcf4

Browse files
committed
Add EF Core 9 migration to align PostgreSQL test model snapshot
The dependency bump to EF Core / Npgsql 9 changed the computed delete behavior of the optional Post.Author foreign key. The checked-in model snapshot (generated under EF Core 8) still recorded OnDelete(Cascade), so MigrateAsync threw PendingModelChangesWarning and failed PostgreSQL integration tests. Regenerate the snapshot and add a migration dropping the cascade to match the current model.
1 parent 42ab7dd commit 596dcf4

3 files changed

Lines changed: 195 additions & 3 deletions

File tree

src/CoreSync.Tests/Migrations/PostgreSQLMigrations/20260619103051_FixAuthorEmailForeignKeyCascade.Designer.cs

Lines changed: 152 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace CoreSync.Tests.Migrations.PostgreSQLMigrations
6+
{
7+
/// <inheritdoc />
8+
public partial class FixAuthorEmailForeignKeyCascade : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.DropForeignKey(
14+
name: "FK_Posts_Users_AuthorEmail",
15+
table: "Posts");
16+
17+
migrationBuilder.AddForeignKey(
18+
name: "FK_Posts_Users_AuthorEmail",
19+
table: "Posts",
20+
column: "AuthorEmail",
21+
principalTable: "Users",
22+
principalColumn: "Email");
23+
}
24+
25+
/// <inheritdoc />
26+
protected override void Down(MigrationBuilder migrationBuilder)
27+
{
28+
migrationBuilder.DropForeignKey(
29+
name: "FK_Posts_Users_AuthorEmail",
30+
table: "Posts");
31+
32+
migrationBuilder.AddForeignKey(
33+
name: "FK_Posts_Users_AuthorEmail",
34+
table: "Posts",
35+
column: "AuthorEmail",
36+
principalTable: "Users",
37+
principalColumn: "Email",
38+
onDelete: ReferentialAction.Cascade);
39+
}
40+
}
41+
}

src/CoreSync.Tests/Migrations/PostgreSQLMigrations/PostgreSQLBlogDbContextModelSnapshot.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1717
{
1818
#pragma warning disable 612, 618
1919
modelBuilder
20-
.HasAnnotation("ProductVersion", "8.0.10")
20+
.HasAnnotation("ProductVersion", "9.0.17")
2121
.HasAnnotation("Relational:MaxIdentifierLength", 63);
2222

2323
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -127,8 +127,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
127127
{
128128
b.HasOne("CoreSync.Tests.Data.User", "Author")
129129
.WithMany("Posts")
130-
.HasForeignKey("AuthorEmail")
131-
.OnDelete(DeleteBehavior.Cascade);
130+
.HasForeignKey("AuthorEmail");
132131

133132
b.Navigation("Author");
134133
});

0 commit comments

Comments
 (0)