Fixed #22447 -- Make sure custom model bases can be migrated.

Thanks to cdestigter for the report.