diff --git a/src/Entity/Flagging.php b/src/Entity/Flagging.php
index 3787e89..a49b758 100644
--- a/src/Entity/Flagging.php
+++ b/src/Entity/Flagging.php
@@ -6,6 +6,7 @@
 
 namespace Drupal\flag\Entity;
 
+use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Entity\ContentEntityBase;
 use Drupal\Core\Field\BaseFieldDefinition;
@@ -37,8 +38,29 @@ use Drupal\flag\FlaggingInterface;
  * )
  */
 class Flagging extends ContentEntityBase implements FlaggingInterface {
+
   // @todo should there be a data_table annotation?
   // @todo should the bundle entity_key annotation be "flag" not "type"?
+
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function preCreate(EntityStorageInterface $storage, array &$values) {
+    parent::preCreate($storage, $values);
+    $values['flagged_entity'] = $values['entity_id'];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function postLoad(EntityStorageInterface $storage, array &$entities) {
+    parent::postLoad($storage, $entities);
+    foreach ($entities as $entity) {
+      $entity->flagged_entity->target_id = $entity->entity_id->value;
+    }
+  }
+
   /**
    * Gets the flag ID for the parent flag.
    *
@@ -116,6 +138,11 @@ class Flagging extends ContentEntityBase implements FlaggingInterface {
       ->setRequired(TRUE)
       ->setDescription(t('The Entity ID.'));
 
+    $fields['flagged_entity'] = BaseFieldDefinition::create('entity_reference')
+      ->setLabel(t('Entity'))
+      ->setDescription(t('The flagged entity.'))
+      ->setComputed(TRUE);
+
     // Also duplicates data on flag entity for querying purposes.
     $fields['global'] = BaseFieldDefinition::create('boolean')
       ->setLabel(t('Global'))
@@ -136,4 +163,17 @@ class Flagging extends ContentEntityBase implements FlaggingInterface {
     return $fields;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
+    /** @var Flag $flag */
+    if ($flag = Flag::load($bundle)) {
+      $fields['flagged_entity'] = clone $base_field_definitions['flagged_entity'];
+      $fields['flagged_entity']->setSetting('target_type', $flag->getFlaggableEntityTypeId());
+      return $fields;
+    }
+    return parent::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions); // TODO: Change the autogenerated stub
+  }
+
 }
diff --git a/src/Tests/FlagSimpleTest.php b/src/Tests/FlagSimpleTest.php
index e97adfa..f25e09e 100644
--- a/src/Tests/FlagSimpleTest.php
+++ b/src/Tests/FlagSimpleTest.php
@@ -117,6 +117,15 @@ class FlagSimpleTest extends FlagTestBase {
     $this->drupalGet('node/' . $node_id);
     $this->clickLink('Flag this item');
     $this->assertResponse(200);
+    $flaggings = \Drupal::entityTypeManager()->getStorage('flagging')->loadMultiple();
+    $this->assertEqual(count($flaggings), 1);
+    // Test the calculated entity reference field. Calculated fields are rare
+    // so a few extra asserts can't hurt.
+    $flagging = reset($flaggings);
+    $this->assertEqual($flagging->flagged_entity->getSetting('target_type'), 'node');
+    $this->assertEqual($flagging->flagged_entity->target_id, $node_id);
+    $this->assertEqual($flagging->flagged_entity->entity->id(), $node_id);
+    $this->assertEqual($flagging->flagged_entity->entity->getEntityTypeId(), 'node');
     $this->assertLink('Unflag this item');
 
     // Switch user to check flagging link.
