How to check if a multi value reference field already has a value
You can check the field's values before saving:

// Id to check if exists.
$query_id = 123;

// Create array of existing ids in field.
$existing_ids = array_column($entity-&gt;my_entity_reference_field-&gt;getValue(), 'target_id');

// Check if the $query_id is not in the existing ids.
if (!in_array($query_id, $existing_ids)) {
  // In here means your $query_id doesn't already exist in the field's values.
}



Your code updated:

// Load portfolio node id and new location id from form_state.
$portfolioId = $form_state-&gt;getValue('portfolios');
$newLocationId = $form_state-&gt;getValue('location_nid');
if (!empty($portfolioId) &amp;&amp; !empty($newLocationId)) {
  // Load portfolio node.
  $portfolioNode = \Drupal::entityTypeManager()
    -&gt;getStorage('node')
    -&gt;load($portfolioId);

  // Get existing location ids from portfolio node.
  $existingPortfolioLocationIds = array_column($portfolioNode-&gt;field_portfolio_locations-&gt;getValue(), 'target_id');
  // If new location id is not an existing location id, add to node and save.
  if (!in_array($newLocationId, $existingPortfolioLocationIds)) {
    $portfolioNode-&gt;field_portfolio_locations[] = $newLocationId;
    $portfolioNode-&gt;save();
  }
}