diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
index 6ecf791..4899f36 100644
--- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
+++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
@@ -9,8 +9,11 @@
 
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Entity\Query\QueryFactory;
 use Drupal\Core\State\StateInterface;
 use Drupal\migrate\Entity\MigrationInterface;
+use Drupal\migrate\MigrateException;
+use Drupal\migrate\MigrateSkipRowException;
 use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
 use Drupal\migrate\Row;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -30,6 +33,20 @@ class EntityComment extends EntityContentBase {
   protected $state;
 
   /**
+   * The entity query object.
+   *
+   * @var \Drupal\Core\Entity\Query\QueryInterface
+   */
+  protected $entityQuery;
+
+  /**
+   * An array of entity Ids for the 'commented entity' keyed by entity type.
+   *
+   * @var array
+   */
+  protected $stubCommentedEntityIds;
+
+  /**
    * Builds an comment entity destination.
    *
    * @param array $configuration
@@ -48,10 +65,13 @@ class EntityComment extends EntityContentBase {
    *   The entity manager service.
    * @param \Drupal\Core\State\StateInterface $state
    *   The state storage object.
+   * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
+   *   The query object that can query the given entity type.
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, StateInterface $state) {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, StateInterface $state, QueryFactory $entity_query) {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
     $this->state = $state;
+    $this->entityQuery = $entity_query;
   }
 
   /**
@@ -67,7 +87,8 @@ public static function create(ContainerInterface $container, array $configuratio
       $container->get('entity.manager')->getStorage($entity_type),
       array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
       $container->get('entity.manager'),
-      $container->get('state')
+      $container->get('state'),
+      $container->get('entity.query')
     );
   }
 
@@ -85,4 +106,38 @@ public function import(Row $row, array $old_destination_id_values = array()) {
     return $return;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function processStubRow(Row $row) {
+    parent::processStubRow($row);
+    $stub_commented_entity_type = $row->getDestinationProperty('entity_type');
+
+    // While parent::getEntity() fills the bundle property for stub entities
+    // if it's still empty, here we must also make sure entity_id/entity_type
+    // are filled (so $comment->getCommentedEntity() always returns a value).
+    if (empty($this->stubCommentedEntityIds[$stub_commented_entity_type])) {
+      // Fill stub entity id. Any id will do, as long as it exists.
+      $entity_type = $this->entityManager->getDefinition($stub_commented_entity_type);
+      if ($id_key = $entity_type->getKey('id')) {
+        $result = $this->entityQuery
+          ->get($stub_commented_entity_type)
+          ->range(0, 1)
+          ->execute();
+        if ($result) {
+          $this->stubCommentedEntityIds[$stub_commented_entity_type] = array_pop($result);
+          $row->setSourceProperty($id_key, $this->stubCommentedEntityIds[$stub_commented_entity_type]);
+        }
+      }
+    }
+    if (empty($this->stubCommentedEntityIds[$stub_commented_entity_type])) {
+      throw new MigrateException(t('Could not derive commented entity for comment %id', ['%id' => implode(':', $row->getSourceIdValues())]), MigrationInterface::MESSAGE_ERROR);
+    }
+
+    $row->setDestinationProperty('entity_id', $this->stubCommentedEntityIds[$stub_commented_entity_type]);
+    $row->setDestinationProperty('entity_type', $stub_commented_entity_type);
+    $row->setDestinationProperty('created', REQUEST_TIME);
+    $row->setDestinationProperty('changed', REQUEST_TIME);
+  }
+
 }
diff --git a/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php b/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php
index 0458c54..a4c08d4 100644
--- a/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php
+++ b/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php
@@ -19,7 +19,10 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
 
   use CommentTestTrait;
 
-  static $modules = array('node', 'comment', 'text', 'filter');
+  // Directly testing that comments' entity_id is populated upon importing is
+  // not straightforward, but RDF module serves as an implicit test;
+  // its hook_comment_storage_load() references $comment->getCommentedEntity().
+  static $modules = ['node', 'comment', 'text', 'filter', 'rdf'];
 
   /**
    * {@inheritdoc}
@@ -30,8 +33,12 @@ protected function setUp() {
     $this->installEntitySchema('node');
     $this->installEntitySchema('comment');
     $this->installSchema('comment', ['comment_entity_statistics']);
+    $this->installSchema('system', ['router']);
     $this->installConfig(['node', 'comment']);
 
+    // The entity.node.canonical route must exist when the RDF hook is called.
+    $this->container->get('router.builder')->rebuild();
+
     entity_create('node_type', array('type' => 'page'))->save();
     entity_create('node_type', array('type' => 'story'))->save();
     $this->addDefaultCommentField('node', 'story');
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
index 69ff3e5..c3cc71b 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
@@ -113,12 +113,11 @@ protected function getEntity(Row $row, array $old_destination_id_values) {
       $this->updateEntity($entity, $row);
     }
     else {
-      $values = $row->getDestination();
-      // Stubs might not have the bundle specified.
+      // Stubs might need some required fields filled in.
       if ($row->isStub()) {
-        $values = $this->processStubValues($values);
+        $this->processStubRow($row);
       }
-      $entity = $this->storage->create($values);
+      $entity = $this->storage->create($row->getDestination());
       $entity->enforceIsNew();
     }
     return $entity;
@@ -139,21 +138,14 @@ protected function getEntityId(Row $row) {
   /**
    * Process the stub values.
    *
-   * @param array $values
-   *   An array of destination values.
-   *
-   * @return array
-   *   The processed stub values.
+   * @param \Drupal\migrate\Row $row
+   *   The row of data.
    */
-  protected function processStubValues(array $values) {
-    $values = array_intersect_key($values, $this->getIds());
-
+  protected function processStubRow(Row $row) {
     $bundle_key = $this->getKey('bundle');
-    if ($bundle_key && !isset($values[$bundle_key])) {
-      $values[$bundle_key] = reset($this->bundles);
+    if ($bundle_key && empty($row->getDestinationProperty($bundle_key))) {
+      $row->setDestinationProperty($bundle_key, reset($this->bundles));
     }
-
-    return $values;
   }
 
   /**
