Updated patch for entity reference.