Fix many to many code generation bug