diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
index a3d8e0a..e288a21 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
@@ -11,6 +11,7 @@
 use Drupal\Core\Entity\Plugin\DataType\EntityReference;
 use Drupal\Core\Entity\Query\QueryException;
 use Drupal\field\Entity\Field;
+use Drupal\field\Field as FieldInfo;
 
 /**
  * Adds tables and fields to the SQL entity query.
@@ -54,6 +55,8 @@ public function __construct(SelectInterface $sql_query) {
    */
   public function addField($field, $type, $langcode) {
     $entity_type = $this->sqlQuery->getMetaData('entity_type');
+    $entity_manager = \Drupal::entityManager();
+    $field_info = FieldInfo::fieldInfo();
     $age = $this->sqlQuery->getMetaData('age');
     // This variable ensures grouping works correctly. For example:
     // ->condition('tags', 2, '>')
@@ -69,12 +72,12 @@ public function addField($field, $type, $langcode) {
     // This will contain the definitions of the last specifier seen by the
     // system.
     $propertyDefinitions = array();
-    $entity_info = entity_get_info($entity_type);
+    $entity_info = $entity_manager->getDefinition($entity_type);
     // Use the lightweight and fast field map for checking whether a specifier
     // is a field or not. While calling field_info_field() on every specifier
     // delivers the same information, if no specifiers are using the field API
     // it is much faster if field_info_field() is never called.
-    $field_map = field_info_field_map();
+    $field_map = $field_info->getFieldMap();
     for ($key = 0; $key <= $count; $key ++) {
       // If there is revision support and only the current revision is being
       // queried then use the revision id. Otherwise, the entity id will do.
@@ -97,10 +100,10 @@ public function addField($field, $type, $langcode) {
       // Normally it is a field name, but field_purge_batch() is passing in
       // id:$field_id so check that first.
       if (substr($specifier, 0, 3) == 'id:') {
-        $field = field_info_field_by_id(substr($specifier, 3));
+        $field = $field_info->getFieldById((substr($specifier, 3)));
       }
       elseif (isset($field_map[$specifier])) {
-        $field = field_info_field($specifier);
+        $field = $field_info->getField($specifier);
       }
       else {
         $field = FALSE;
@@ -129,8 +132,17 @@ public function addField($field, $type, $langcode) {
             $relationship_specifier = $specifiers[$key + 1];
 
             // Get the field definitions form a mocked entity.
-            $entity = entity_create($entity_type, array());
-            $propertyDefinitions = $entity->{$field['field_name']}->getPropertyDefinitions();
+            $values = array();
+            $field_name = $field->getFieldName();
+            // If there are bundles, pick one.
+            if (!empty($entity_info['entity_keys']['bundle'])) {
+              $values[$entity_info['entity_keys']['bundle']] = reset($field_map[$field_name]['bundles'][$entity_type]);
+            }
+            $entity = $entity_manager
+              ->getStorageController($entity_type)
+              ->create($values)
+              ->getNGEntity();
+            $propertyDefinitions = $entity->$field_name->getPropertyDefinitions();
 
             // If the column is not yet known, ie. the
             // $node->field_image->entity case then use first property as
@@ -176,10 +188,14 @@ public function addField($field, $type, $langcode) {
           $values = array();
           // If there are bundles, pick one. It does not matter which,
           // properties exist on all bundles.
-          if (!empty($entity_info['entity keys']['bundle'])) {
-            $values[$entity_info['entity keys']['bundle']] = key(entity_get_bundles('node'));
+          if (!empty($entity_info['entity_keys']['bundle'])) {
+            $bundles = entity_get_bundles($entity_type);
+            $values[$entity_info['entity_keys']['bundle']] = key($bundles);
           }
-          $entity = entity_create($entity_type, $values);
+          $entity = $entity_manager
+            ->getStorageController($entity_type)
+            ->create($values)
+            ->getNGEntity();
           $propertyDefinitions = $entity->$specifier->getPropertyDefinitions();
           $relationship_specifier = $specifiers[$key + 1];
           $next_index_prefix = $relationship_specifier;
@@ -188,7 +204,7 @@ public function addField($field, $type, $langcode) {
         if (isset($propertyDefinitions[$relationship_specifier]) && $entity->{$specifier}->get('entity') instanceof EntityReference) {
           // If it is, use the entity type.
           $entity_type = $propertyDefinitions[$relationship_specifier]['constraints']['EntityType'];
-          $entity_info = entity_get_info($entity_type);
+          $entity_info = $entity_manager->getDefinition($entity_type);
           // Add the new entity base table using the table and sql column.
           $join_condition= '%alias.' . $entity_info['entity_keys']['id'] . " = $table.$sql_column";
           $base_table = $this->sqlQuery->leftJoin($entity_info['base_table'], NULL, $join_condition);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
index ae99e9d..114ba79 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
@@ -86,11 +86,12 @@ public function setUp() {
     );
     $field['settings']['allowed_values']['vocabulary'] = $vocabulary->id();
     entity_create('field_entity', $field)->save();
+    entity_test_create_bundle('test_bundle');
     // Third, create the instance.
     entity_create('field_instance', array(
       'entity_type' => 'entity_test',
       'field_name' => $this->fieldName,
-      'bundle' => 'entity_test',
+      'bundle' => 'test_bundle',
     ))->save();
     // Create two terms and also two accounts.
     for ($i = 0; $i <= 1; $i++) {
@@ -106,7 +107,7 @@ public function setUp() {
     // 0th account and 0th term, the 1st and 2nd entity will point to the
     // 1st account and 1st term.
     for ($i = 0; $i <= 2; $i++) {
-      $entity = entity_create('entity_test', array());
+      $entity = entity_create('entity_test', array('type' => 'test_bundle'));
       $entity->name->value = $this->randomName();
       $index = $i ? 1 : 0;
       $entity->user_id->target_id = $this->accounts[$index]->id();
