diff --git a/core/modules/views/src/Plugin/views/field/EntityField.php b/core/modules/views/src/Plugin/views/field/EntityField.php
index 4c8032d..59b7d2d 100644
--- a/core/modules/views/src/Plugin/views/field/EntityField.php
+++ b/core/modules/views/src/Plugin/views/field/EntityField.php
@@ -230,7 +230,7 @@ public function query($use_groupby = FALSE) {
       unset($fields[$entity_type_key]);
     }
 
-    if ($use_groupby) {
+    if ($use_groupby && !empty($this->options['group_column'])) {
       // Add the fields that we're actually grouping on.
       $options = array();
       if ($this->options['group_column'] != 'entity_id') {
@@ -265,7 +265,7 @@ public function query($use_groupby = FALSE) {
    */
   function add_field_table($use_groupby) {
     // Grouping is enabled.
-    if ($use_groupby) {
+    if ($use_groupby && !empty($this->options['group_column'])) {
       return TRUE;
     }
     // This a multiple value field, but "group multiple values" is not checked.
@@ -344,13 +344,16 @@ protected function defineOptions() {
     $field_storage_definition = $this->getFieldStorageDefinition();
     $field_type = $this->fieldTypePluginManager->getDefinition($field_storage_definition->getType());
     $column_names = array_keys($field_storage_definition->getColumns());
-    $default_column = '';
-    // Try to determine a sensible default.
-    if (count($column_names) == 1) {
-      $default_column = $column_names[0];
-    }
-    elseif (in_array('value', $column_names)) {
-      $default_column = 'value';
+    $default_column = $field_storage_definition->getMainPropertyName() ?: '';
+    // Try to determine a sensible default if none if provided by the field
+    // definition.
+    if (!$default_column) {
+      if (count($column_names) == 1) {
+        $default_column = $column_names[0];
+      }
+      elseif (in_array('value', $column_names)) {
+        $default_column = 'value';
+      }
     }
 
     // If the field has a "value" column, we probably need that one.
diff --git a/core/modules/views/tests/src/Kernel/QueryGroupByTest.php b/core/modules/views/tests/src/Kernel/QueryGroupByTest.php
index 594bd62..361900d 100644
--- a/core/modules/views/tests/src/Kernel/QueryGroupByTest.php
+++ b/core/modules/views/tests/src/Kernel/QueryGroupByTest.php
@@ -2,10 +2,14 @@
 
 namespace Drupal\Tests\views\Kernel;
 
+use Drupal\entity_test\Entity\EntityTest;
 use Drupal\entity_test\Entity\EntityTestMul;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\file\Entity\File;
+use Drupal\image\Entity\ImageStyle;
 use Drupal\language\Entity\ConfigurableLanguage;
+use Drupal\views\Entity\View;
 use Drupal\views\Views;
 
 /**
@@ -20,14 +24,14 @@ class QueryGroupByTest extends ViewsKernelTestBase {
    *
    * @var array
    */
-  public static $testViews = array('test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle');
+  public static $testViews = array('test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle', 'entity_test_fields');
 
   /**
    * Modules to enable.
    *
    * @var array
    */
-  public static $modules = array('entity_test', 'system', 'field', 'user', 'language');
+  public static $modules = array('entity_test', 'system', 'field', 'user', 'language', 'file', 'image');
 
   /**
    * The storage for the test entity type.
@@ -331,4 +335,84 @@ public function testGroupByWithFieldsNotExistingOnBundle() {
     $this->assertEqual('1', $view->getStyle()->getField(1, 'field_test'));
   }
 
+  /**
+   * Tests aggregation on fields with multiple columns.
+   */
+  public function testGroupByFieldWithMultipleColumns() {
+    $this->installEntitySchema('entity_test');
+    $this->installEntitySchema('file');
+    $this->installSchema('file', 'file_usage');
+    /** @var \Drupal\image\ImageStyleInterface $style */
+    $style = ImageStyle::create(['name' => 'foo']);
+    $style->save();
+
+    // Create a new image field 'bar' to be used in 'entity_test_fields' view.
+    FieldStorageConfig::create([
+      'entity_type' => 'entity_test',
+      'field_name' => 'image_field',
+      'type' => 'image',
+    ])->save();
+    FieldConfig::create([
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+      'field_name' => 'image_field',
+      'settings' => [
+        'file_extensions' => 'jpg',
+      ]
+    ])->save();
+
+    /** @var \Drupal\views\ViewEntityInterface $view */
+    $view = View::load('entity_test_fields');
+    $display =& $view->getDisplay('default');
+
+    // Set the image field as the only field so it should be used for grouping
+    // when aggregation is enabled.
+    $display['display_options']['fields'] = [
+      'image_field' => [
+        'id' => 'image_field',
+        'field' => 'image_field',
+        'plugin_id' => 'field',
+        'table' => 'entity_test__image_field',
+        'entity_type' => 'entity_test',
+        'entity_field' => 'image_field',
+        'type' => 'image',
+        'settings' => ['image_style' => 'foo', 'image_link' => ''],
+      ],
+    ];
+    $display['display_options']['arguments'] = [];
+    $display['display_options']['sorts'] = [];
+    $display['display_options']['group_by'] = TRUE;
+    $view->save();
+
+    $file = File::create(array(
+      'filename' => 'druplicon.jpg',
+      'uri' => "public://druplicon.jpg",
+      'filemime' => 'image/jpeg',
+      'status' => FILE_STATUS_PERMANENT,
+    ));
+    $file_two = File::create(array(
+      'filename' => 'druplicon-two.jpg',
+      'uri' => "public://druplicon-two.jpg",
+      'filemime' => 'image/jpeg',
+      'status' => FILE_STATUS_PERMANENT,
+    ));
+
+    $entity_one = EntityTest::create();
+    $entity_one->set('image_field', $file);
+    $entity_one->save();
+
+    $entity_two = EntityTest::create();
+    $entity_two->set('image_field', $file);
+    $entity_two->save();
+
+    $entity_three = EntityTest::create();
+    $entity_three->set('image_field', $file_two);
+    $entity_three->save();
+
+    $view_executable = $view->getExecutable();
+    $this->executeView($view_executable);
+    // By default the rows should now be grouped by target_id.
+    $this->assertCount(2, $view_executable->result);
+  }
+
 }
diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
index 2b929f3..f658f4d 100644
--- a/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
@@ -495,6 +495,71 @@ public function testQueryWithGroupByForBaseField() {
   /**
    * @covers ::query
    */
+  public function testQueryWithGroupByForBaseFieldFailure() {
+    $definition = [
+      'entity_type' => 'test_entity',
+      'field_name' => 'title',
+    ];
+    $handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
+    $handler->view = $this->executable;
+    $handler->view->field = [$handler];
+
+    $this->setupLanguageRenderer($handler, $definition);
+
+    $field_storage = $this->getBaseFieldStorage();
+    $this->entityManager->expects($this->any())
+      ->method('getFieldStorageDefinitions')
+      ->with('test_entity')
+      ->willReturn([
+        'title' => $field_storage,
+      ]);
+
+    $table_mapping = $this->getMock('Drupal\Core\Entity\Sql\TableMappingInterface');
+    $table_mapping
+      ->expects($this->any())
+      ->method('getFieldColumnName')
+      ->with($field_storage, 'value')
+      ->willReturn('title');
+    $entity_storage = $this->getMock('Drupal\Core\Entity\Sql\SqlEntityStorageInterface');
+    $entity_storage->expects($this->any())
+      ->method('getTableMapping')
+      ->willReturn($table_mapping);
+    $this->entityManager->expects($this->any())
+      ->method('getStorage')
+      ->with('test_entity')
+      ->willReturn($entity_storage);
+
+    $options = [
+      'group_column' => NULL,
+      'group_columns' => [],
+      'table' => 'test_entity_table',
+    ];
+    $handler->init($this->executable, $this->display, $options);
+
+    $query = $this->getMockBuilder('Drupal\views\Plugin\views\query\Sql')
+      ->disableOriginalConstructor()
+      ->getMock();
+    $query->expects($this->any())
+      ->method('ensureTable')
+      ->with('test_entity_table', NULL)
+      ->willReturn('test_entity_table');
+    // Ensure that we add the title field to the query, if we group by some
+    // other field in the view.
+    $query->expects($this->any())
+      ->method('addField')
+      ->with('test_entity_table', 'title');
+
+    $this->executable->query = $query;
+
+    $handler->query(TRUE);
+
+    $this->assertObjectNotHasAttribute('group_fields', $handler);
+    $this->assertNull($handler->tableAlias);
+  }
+
+  /**
+   * @covers ::query
+   */
   public function testQueryWithGroupByForConfigField() {
     $definition = [
       'entity_type' => 'test_entity',
@@ -555,6 +620,71 @@ public function testQueryWithGroupByForConfigField() {
   }
 
   /**
+   * @covers ::query
+   */
+  public function testQueryWithGroupByForConfigFieldFailure() {
+    $definition = [
+      'entity_type' => 'test_entity',
+      'field_name' => 'body',
+    ];
+    $handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
+    $handler->view = $this->executable;
+    $handler->view->field = [$handler];
+
+    $this->setupLanguageRenderer($handler, $definition);
+
+    $field_storage = $this->getConfigFieldStorage();
+    $this->entityManager->expects($this->any())
+      ->method('getFieldStorageDefinitions')
+      ->with('test_entity')
+      ->willReturn([
+        'body' => $field_storage,
+      ]);
+
+    $table_mapping = $this->getMock('Drupal\Core\Entity\Sql\TableMappingInterface');
+    $table_mapping
+      ->expects($this->any())
+      ->method('getFieldColumnName')
+      ->with($field_storage, 'value')
+      ->willReturn('body_value');
+    $entity_storage = $this->getMock('Drupal\Core\Entity\Sql\SqlEntityStorageInterface');
+    $entity_storage->expects($this->any())
+      ->method('getTableMapping')
+      ->willReturn($table_mapping);
+    $this->entityManager->expects($this->any())
+      ->method('getStorage')
+      ->with('test_entity')
+      ->willReturn($entity_storage);
+
+    $options = [
+      'group_column' => NULL,
+      'group_columns' => [],
+      'table' => 'test_entity__body',
+    ];
+    $handler->init($this->executable, $this->display, $options);
+
+    $query = $this->getMockBuilder('Drupal\views\Plugin\views\query\Sql')
+      ->disableOriginalConstructor()
+      ->getMock();
+    $query->expects($this->any())
+      ->method('ensureTable')
+      ->with('test_entity__body', NULL)
+      ->willReturn('test_entity__body');
+    // Ensure that we add the title field to the query, if we group by some
+    // other field in the view.
+    $query->expects($this->any())
+      ->method('addField')
+      ->with('test_entity__body', 'body_value');
+
+    $this->executable->query = $query;
+
+    $handler->query(TRUE);
+
+    $this->assertObjectNotHasAttribute('group_fields', $handler);
+    $this->assertNull($handler->tableAlias);
+  }
+
+  /**
    * @covers ::prepareItemsByDelta
    *
    * @dataProvider providerTestPrepareItemsByDelta
@@ -722,6 +852,60 @@ protected function setupLanguageRenderer(EntityField $handler, $definition) {
       ->willReturn($entity_type);
   }
 
+  /**
+   * @covers ::add_field_table
+   */
+  public function testAddAdditionalFieldTable() {
+    $definition = [
+      'entity_type' => 'test_entity',
+      'field_name' => 'body',
+    ];
+    $handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
+    $handler->view = $this->executable;
+    $handler->view->field = [$handler];
+
+    $this->setupLanguageRenderer($handler, $definition);
+
+    $field_storage = $this->getConfigFieldStorage();
+    $this->entityManager->expects($this->any())
+      ->method('getFieldStorageDefinitions')
+      ->with('test_entity')
+      ->willReturn([
+        'body' => $field_storage,
+      ]);
+
+    $table_mapping = $this->getMock('Drupal\Core\Entity\Sql\TableMappingInterface');
+    $table_mapping
+      ->expects($this->any())
+      ->method('getFieldColumnName')
+      ->with($field_storage, 'value')
+      ->willReturn('body_value');
+    $entity_storage = $this->getMock('Drupal\Core\Entity\Sql\SqlEntityStorageInterface');
+    $entity_storage->expects($this->any())
+      ->method('getTableMapping')
+      ->willReturn($table_mapping);
+    $this->entityManager->expects($this->any())
+      ->method('getStorage')
+      ->with('test_entity')
+      ->willReturn($entity_storage);
+
+    $options = [
+      'group_column' => NULL,
+      'group_columns' => [],
+      'table' => 'test_entity__body',
+    ];
+    $handler->init($this->executable, $this->display, $options);
+    $handler->query = $this->getMockBuilder('Drupal\views\Plugin\views\query\Sql')
+      ->disableOriginalConstructor()
+      ->getMock();
+
+    $handler->additional_fields = ['alt', 'title'];
+    $handler->query(TRUE);
+
+    $this->assertEmpty($handler->tableAlias);
+    $this->assertEmpty($handler->aliases);
+  }
+
 }
 
 class FieldTestEntityField extends EntityField {
