Creates a function that populates all references on a model