diff --git a/src/Plugin/migrate/process/EntityLookup.php b/src/Plugin/migrate/process/EntityLookup.php
index 0d044b441bf328bc21dd5cf4a0af575bad779adf..7ed4e84d27c0a090c356c0210a04d09ab7481c32 100644
--- a/src/Plugin/migrate/process/EntityLookup.php
+++ b/src/Plugin/migrate/process/EntityLookup.php
@@ -261,6 +261,11 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn
     $query = $this->entityManager->getStorage($this->lookupEntityType)
       ->getQuery()
       ->condition($this->lookupValueKey, $value, $multiple ? 'IN' : NULL);
+    // Sqlite and possibly others returns data in a non-deterministic order.
+    // Make it deterministic.
+    if ($multiple) {
+      $query->sort($this->lookupValueKey, 'DESC');
+    }
 
     if ($this->lookupBundleKey) {
       $query->condition($this->lookupBundleKey, $this->lookupBundle);
diff --git a/tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php b/tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php
index fb9f7891507fb5688e7f1937a2e1f6804328ad9e..3a52918176ad8a29aebd368661a1de6209425904 100644
--- a/tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php
+++ b/tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php
@@ -171,14 +171,14 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
                 foreach ($valueToCheck as $key => $expectedValue) {
                   if (empty($expectedValue)) {
                     if (!$entity->{$property}->isEmpty()) {
-                      $this->assertTrue($entity->{$property}[0]->entity->$key->isEmpty(), "Expected value is empty but field $property.$key is not empty.");
+                      $this->assertTrue($entity->{$property}[0]->entity->{$key}->isEmpty(), "Expected value is empty but field $property.$key is not empty.");
                     }
                     else {
-                      $this->assertTrue($entity->{$property}->isEmpty(), "FOOBAR Expected value is empty but field $property is not empty.");
+                      $this->assertTrue($entity->{$property}->isEmpty(), "Expected value is empty but field $property is not empty.");
                     }
                   }
                   elseif ($entity->{$property}->getValue()) {
-                    $this->assertEquals($expectedValue, $entity->{$property}[$valueID]->entity->$key->value);
+                    $this->assertEquals($expectedValue, $entity->get($property)->offsetGet($valueID)->entity->{$key}->value);
                   }
                   else {
                     $this->fail("Expected value: $expectedValue does not exist in $property.");
@@ -192,7 +192,7 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
               foreach ($value as $key => $expectedValue) {
                 if (empty($expectedValue)) {
                   if (!$entity->{$property}->isEmpty()) {
-                    $this->assertTrue($entity->{$property}[0]->entity->$key->isEmpty(), "Expected value is empty but field $property.$key is not empty.");
+                    $this->assertTrue($entity->{$property}[0]->entity->{$key}->isEmpty(), "Expected value is empty but field $property.$key is not empty.");
                   }
                   else {
                     $this->assertTrue($entity->{$property}->isEmpty(), "BINBAZ Expected value is empty but field $property is not empty.");