I migrate Drupal 6 to Drupal 8. In Drupal 8 I have content type that has field with type Entity reference that reference specific taxonomy dictionary. I can't find out how to set Entity reference field target_id in yml migration file. I have tried:

  plugin: iterator
  source: field_my_field
      plugin: default_value
      default_value: 19

I would expect that code above set Entity reference (field_my_field) to reference term with id 19 (that already exists). There is no error (or message) and default_value plugin is called correctly a returns 19. But in migrated content is not reference set.

I tried to set reference manually and then dump it and result was:

[field_my_field] => Array
    [x-default] => Array
        [0] => Array
            [target_id] => 19

I have tried lot of other ways how to set entity reference target_id but nothing actually work. Do anybody know how to set entity reference target_id in migration yml file?

  • 1
    Hi do you any update on this? I'm facing the same situation, my code is very similar, everything seems to run well, but the association is not saved.
    – jchatard
    Commented Sep 21, 2017 at 15:43

2 Answers 2


Old question, but I'm guessing you need to add the array for the item list. I was successful with: field_something/0/target_id: YOUR_VALUE_HERE

I haven't found documentation on the slash in the field id, but it is an array notation. The above is equivalent to something like: $destination_values['field_something'][0]['target_id'] = YOUR_VALUE_HERE


Is 19 the tid of an already-existing Drupal 8 term in the vocabulary that field_my_field is configured to reference? If so, I don't really see where the example using default_value would be going wrong...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.