Fixes #2416 - Creation of Many-to-Many associations using indexes

This fixes #2416 which was originally related to #2057 

I am not sure how a test could be constructed against this, its a relatively simple fix as it is.

If I need to add a unit test let me know and point me in the right direction of where to put it and Ill put one together.

I have tested this branch in my local software and it fixes the issue.

Thanks