Automatically attach reference to entity