diff --git a/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php b/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php
index 47822d2..0b90ea3 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\field\Kernel\EntityReference\Views;
 
+use Drupal\entity_test\Entity\EntityTestMulChanged;
 use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
 use Drupal\entity_test\Entity\EntityTest;
 use Drupal\entity_test\Entity\EntityTestMul;
@@ -27,6 +28,7 @@ class EntityReferenceRelationshipTest extends ViewsKernelTestBase {
    */
   public static $testViews = array(
     'test_entity_reference_entity_test_view',
+    'test_entity_reference_entity_test_view_long',
     'test_entity_reference_reverse_entity_test_view',
     'test_entity_reference_entity_test_mul_view',
     'test_entity_reference_reverse_entity_test_mul_view',
@@ -55,6 +57,7 @@ protected function setUp($import_test_views = TRUE) {
     $this->installEntitySchema('user');
     $this->installEntitySchema('entity_test');
     $this->installEntitySchema('entity_test_mul');
+    $this->installEntitySchema('entity_test_mul_changed');
 
     // Create reference from entity_test to entity_test_mul.
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_data', 'field_test_data', 'entity_test_mul');
@@ -62,6 +65,12 @@ protected function setUp($import_test_views = TRUE) {
     // Create reference from entity_test_mul to entity_test.
     $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test', 'field_data_test', 'entity_test');
 
+    // Create another field for testing with a long name. So it's storage name
+    // will become hashed. Use entity_test_mul_changed, so the resulting field
+    // tables created will be grater than 48 chars long.
+    // @see \Drupal\Core\Entity\Sql\DefaultTableMapping::generateFieldTableName()
+    $this->createEntityReferenceField('entity_test_mul_changed', 'entity_test_mul_changed', 'field_test_data_with_a_long_name', 'field_test_data_with_a_long_name', 'entity_test');
+
     ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views'));
   }
 
@@ -124,7 +133,6 @@ public function testNoDataTableRelationship() {
       // Test that the correct relationship entity is on the row.
       $this->assertEqual($row->_relationship_entities['field_test_data']->id(), 1);
       $this->assertEqual($row->_relationship_entities['field_test_data']->bundle(), 'entity_test_mul');
-
     }
 
     // Check the backwards reference view.
@@ -225,4 +233,47 @@ public function testDataTableRelationship() {
     }
   }
 
+  /**
+   * Tests views data generated for relationship.
+   *
+   * @see entity_reference_field_views_data()
+   */
+  public function testDataTableRelationshipWithLongFieldName() {
+    // Create some test entities which link each other.
+    $referenced_entity = EntityTest::create();
+    $referenced_entity->save();
+
+    $entity = EntityTestMulChanged::create();
+    $entity->field_test_data_with_a_long_name->target_id = $referenced_entity->id();
+    $entity->save();
+    $this->entities[] = $entity;
+
+    $entity = EntityTestMulChanged::create();
+    $entity->field_test_data_with_a_long_name->target_id = $referenced_entity->id();
+    $entity->save();
+    $this->entities[] = $entity;
+
+    Views::viewsData()->clear();
+
+    // Check an actual test view.
+    $view = Views::getView('test_entity_reference_entity_test_view_long');
+    $this->executeView($view);
+    /** @var \Drupal\views\ResultRow $row */
+    foreach ($view->result as $index => $row) {
+      // Check that the actual ID of the entity is the expected one.
+      $this->assertEqual($row->id, $this->entities[$index]->id());
+
+      // Also check that we have the correct result entity.
+      $this->assertEqual($row->_entity->id(), $this->entities[$index]->id());
+
+      // Test the forward relationship.
+      //$this->assertEqual($row->entity_test_entity_test_mul__field_data_test_id, 1);
+
+      // Test that the correct relationship entity is on the row.
+      $this->assertEqual($row->_relationship_entities['field_test_data_with_a_long_name']->id(), 1);
+      $this->assertEqual($row->_relationship_entities['field_test_data_with_a_long_name']->bundle(), 'entity_test');
+
+    }
+  }
+
 }
diff --git a/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_entity_test_view_long.yml b/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_entity_test_view_long.yml
new file mode 100644
index 0000000..9978205
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_entity_test_view_long.yml
@@ -0,0 +1,121 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - entity_test
+id: test_entity_reference_entity_test_view_long
+label: test_entity_reference_entity_test_view_long
+module: views
+description: ''
+tag: ''
+base_table: entity_test_mul_changed_property
+base_field: id
+core: 8.x
+display:
+  default:
+    display_plugin: default
+    id: default
+    display_title: Master
+    position: 0
+    display_options:
+      access:
+        type: none
+        options: {  }
+      cache:
+        type: tag
+        options: {  }
+      query:
+        type: views_query
+        options:
+          disable_sql_rewrite: false
+          distinct: false
+          replica: false
+          query_comment: ''
+          query_tags: {  }
+      exposed_form:
+        type: basic
+        options:
+          submit_button: Apply
+          reset_button: false
+          reset_button_label: Reset
+          exposed_sorts_label: 'Sort by'
+          expose_sort_order: true
+          sort_asc_label: Asc
+          sort_desc_label: Desc
+      pager:
+        type: full
+        options:
+          items_per_page: 10
+          offset: 0
+          id: 0
+          total_pages: null
+          expose:
+            items_per_page: false
+            items_per_page_label: 'Items per page'
+            items_per_page_options: '5, 10, 25, 50'
+            items_per_page_options_all: false
+            items_per_page_options_all_label: '- All -'
+            offset: false
+            offset_label: Offset
+          tags:
+            previous: '‹ Previous'
+            next: 'Next ›'
+            first: '« First'
+            last: 'Last »'
+          quantity: 9
+      style:
+        type: default
+        options:
+          grouping: {  }
+          row_class: ''
+          default_row_class: true
+          uses_fields: false
+      row:
+        type: fields
+        options:
+          inline: {  }
+          separator: ''
+          hide_empty: false
+          default_field_elements: true
+      fields:
+        id:
+          id: id
+          table: entity_test_mul_changed_property
+          field: id
+          entity_type: entity_test
+          entity_field: id
+          plugin_id: field
+        id_1:
+          id: id_1
+          table: entity_test
+          field: id
+          entity_type: entity_test
+          entity_field: id
+          plugin_id: field
+          relationship: field_test_data_with_a_long_name
+      filters: {  }
+      sorts:
+        id:
+          id: id
+          table: entity_test_mul_changed_property
+          field: id
+          entity_type: entity_test
+          entity_field: id
+          plugin_id: standard
+      header: {  }
+      footer: {  }
+      empty: {  }
+      relationships:
+        field_test_data_with_a_long_name:
+          id: field_test_data_with_a_long_name_data
+          table: entity_test_mul_changed__field_test_data_with_a_long_name
+          field: field_test_data_with_a_long_name
+          plugin_id: standard
+      arguments: {  }
+      display_extenders: {  }
+    cache_metadata:
+      contexts:
+        - entity_test_view_grants
+        - languages
+        - 'languages:language_interface'
+      max-age: 0
diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php
index 086f179..3fd8a03 100644
--- a/core/modules/views/src/Tests/FieldApiDataTest.php
+++ b/core/modules/views/src/Tests/FieldApiDataTest.php
@@ -64,6 +64,7 @@ function testViewsData() {
     $this->assertTrue(isset($data[$revision_table]['table']['join']['node_field_revision']));
 
     $expected_join = array(
+      'table' => $current_table,
       'left_field' => 'nid',
       'field' => 'entity_id',
       'extra' => array(
@@ -73,6 +74,7 @@ function testViewsData() {
     );
     $this->assertEqual($expected_join, $data[$current_table]['table']['join']['node_field_data']);
     $expected_join = array(
+      'table' => $revision_table,
       'left_field' => 'vid',
       'field' => 'revision_id',
       'extra' => array(
diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc
index aca4b8a..93a659c 100644
--- a/core/modules/views/views.views.inc
+++ b/core/modules/views/views.views.inc
@@ -357,6 +357,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
   if ($data_table) {
     // Tell Views how to join to the base table, via the data table.
     $data[$table_alias]['table']['join'][$data_table] = array(
+      'table' => $table_mapping->getDedicatedDataTableName($field_storage),
       'left_field' => $entity_type->getKey('id'),
       'field' => 'entity_id',
       'extra' => array(
@@ -368,6 +369,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
   else {
     // If there is no data table, just join directly.
     $data[$table_alias]['table']['join'][$base_table] = array(
+      'table' => $table_mapping->getDedicatedDataTableName($field_storage),
       'left_field' => $entity_type->getKey('id'),
       'field' => 'entity_id',
       'extra' => array(
@@ -381,6 +383,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
     if ($entity_revision_data_table) {
       // Tell Views how to join to the revision table, via the data table.
       $data[$table_alias]['table']['join'][$entity_revision_data_table] = array(
+        'table' => $table_mapping->getDedicatedRevisionTableName($field_storage),
         'left_field' => $entity_type->getKey('revision'),
         'field' => 'revision_id',
         'extra' => array(
@@ -392,6 +395,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
     else {
       // If there is no data table, just join directly.
       $data[$table_alias]['table']['join'][$entity_revision_table] = array(
+        'table' => $table_mapping->getDedicatedRevisionTableName($field_storage),
         'left_field' => $entity_type->getKey('revision'),
         'field' => 'revision_id',
         'extra' => array(
