[1.7.x] Fixed #22777: Add dependency on through for autodetected M2M adds