[1.7.x] Fixed #22331 -- Made MigrationAutodetector ignore unmanaged models.
This commit reverts 69d4b1c3 and tackle the issue from a different angle.
Models remain present in the project state, but are now ignored by the
autodetector.
Backport of 42336c84 from master