Description
Found by a pre-release sweep of main @ 934ec55; reproduced in a scratch test. The check is new in the unreleased 5.5.0 (changelog: "a filter … that compares a date or time ToJson() member with a column fails at migrations add").
Problem
ThrowIfFallbackComparedWithColumn (CustomMigrationsModelDiffer.cs:846) runs inside ResolveFilter (:822), which builds descriptors for both sides (ExtractAllIndexDescriptors(source), :148). For exclusion constraints it is reached through ResolveExclusionFilter (NpgsqlComplexIndexMigrationsModelDiffer.cs:1084) from BuildExclusionDescriptors(source) (:841). This breaks the rule that validation runs on the target model only: a snapshot that holds the refused filter can no longer be diffed, which includes the migration that removes the filter.
Scenario: 5.4.x scaffolded "ValidFrom" >= ({Profile.At}) (index) or {Profile.At} <> "ValidFrom" (exclusion), with Profile mapped ToJson() and At a DateTime. After upgrading to 5.5.0 the user removes the declaration, and migrations add throws "compares the JSON member 'Profile.At' with a column" instead of emitting the drop. has-pending-model-changes and Migrate()'s pending-changes check go through the same path (HasDifferences → GetDifferences). The index case needs a snapshot at rendering version ≥ 2; the exclusion case fires at any version.
Change
Record the fallback comparison while resolving, and throw only for target descriptors, next to ValidateQueryUsableLeadingParts.
Tests
NpgsqlDiff(snapshotWithFilter, modelWithoutIt) emits DropIndexOperation ix_at, and for the exclusion case the DROP CONSTRAINT IF EXISTS "ex_at" SQL. Both throw on HEAD. The existing target-side refusal tests stay green.
Activity