Hi Sohaib,
The query which fails is stated in the original post above. It is a model with an ISV solution which is installing fine in every other environment. Only one environment fails. Also if we create a new environment based on the database and modelstore where it goes wrong, it fails. So, I do think there is some reference in the database wrong.