Skip to content

Tests: nothing pins that FKs on tables created in the same migration are no SQLite rebuild #157

Closed

Description

@CaffeinatedCoder

Found in the 5.5.0 pre-tag review (#36) by seeding defects into 934ec55. The code is right today, but nothing pins it.

Seed: in the SQLite rebuild detection (src/EFCore.ComplexIndexes/CustomMigrationsModelDiffer.cs:380), replace AddForeignKeyOperation foreignKey => !created.Contains((foreignKey.Table, foreignKey.Schema)) with => true.

Result: the unit suite still passes, 569/569.

The exception for "a foreign key added to a table created in this same migration" is what keeps new tables with circular foreign keys scaffoldable on SQLite. EF Core emits those as AddForeignKeyOperations, but the tables are not rebuilt. Without the exception, migrations add refuses such a model when UseComplexIndexes() is not wired. The refusal is loud, but it is wrong.

Test to add: create two tables with circular foreign keys plus a complex index, on SQLite, unwired; assert migrations add scaffolds with no refusal. Prove it by re-applying the seed.

Activity

  1. added this to the 5.5.0 milestone on Oct 20, 2026
  2. added
    tests
    package/core
    area/migrations
    on Oct 20, 2026
  3. added 2 commits that reference this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/migrationspackage/coretests

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions