diff --git a/fillpdf.install b/fillpdf.install
index 6b710d250c918800593b4a3c9ada3dadcc4834fa..fe1b1e4c6473a5867407971e9bf57ab70c9f18b9 100644
--- a/fillpdf.install
+++ b/fillpdf.install
@@ -305,3 +305,60 @@ function fillpdf_update_9501() {
   // Commit transaction.
   unset($transaction);
 }
+
+/**
+ * Convert default_entity_id to string.
+ */
+function fillpdf_update_9502() {
+  // @see https://www.drupal.org/docs/drupal-apis/update-api/updating-entities-and-fields-in-drupal-8#s-updating-a-base-field-type
+  $database = \Drupal::database();
+  $transaction = $database->startTransaction();
+
+  $entity_type_manager = \Drupal::entityTypeManager();
+  $bundle_of = 'fillpdf_form';
+  $field_name = 'default_entity_id';
+
+  $storage = $entity_type_manager->getStorage($bundle_of);
+  $bundle_definition = $entity_type_manager->getDefinition($bundle_of);
+  // Sometimes the primary key isn't 'id'. e.g. 'eid' or 'item_id'.
+  $id_key = $bundle_definition->getKey('id');
+  // If there is no data table defined then use the base table.
+  $table_name = $storage->getDataTable() ?: $storage->getBaseTable();
+  $definition_manager = \Drupal::entityDefinitionUpdateManager();
+
+  // Store the existing values.
+  $migrated_values = $database->select($table_name)
+    ->fields($table_name, [$id_key, $field_name])
+    ->execute()
+    ->fetchAllKeyed();
+
+  // Clear out the values.
+  $database->update($table_name)
+    ->fields([$field_name => NULL])
+    ->execute();
+
+  // Uninstall the field.
+  $field_storage_definition = $definition_manager->getFieldStorageDefinition($field_name, $bundle_of);
+  $definition_manager->uninstallFieldStorageDefinition($field_storage_definition);
+
+  // Create a new field definition.
+  $new_field = BaseFieldDefinition::create('string')
+    ->setName($field_name)
+    ->setProvider($bundle_of)
+    ->setTargetBundle(NULL)
+    ->setTargetEntityTypeId($bundle_of);
+
+  // Install the new definition.
+  $definition_manager->installFieldStorageDefinition($field_name, $bundle_of, $bundle_of, $new_field);
+
+  // Restore the values.
+  foreach ($migrated_values as $id => $value) {
+    $database->update($table_name)
+      ->fields([$field_name => (string) $value])
+      ->condition($id_key, $id)
+      ->execute();
+  }
+
+  // Commit transaction.
+  unset($transaction);
+}
diff --git a/src/Entity/FillPdfForm.php b/src/Entity/FillPdfForm.php
index b54da353af58c55ad380920472f1fde98286fdce..7b5acf4c0f93f06c7e234f6442961c3be25a422a 100644
--- a/src/Entity/FillPdfForm.php
+++ b/src/Entity/FillPdfForm.php
@@ -110,7 +110,7 @@ class FillPdfForm extends ContentEntityBase implements FillPdfFormInterface {
     $fields['default_entity_type'] = BaseFieldDefinition::create('string');
 
     // Form element is set up in FillPdfFormForm.
-    $fields['default_entity_id'] = BaseFieldDefinition::create('integer');
+    $fields['default_entity_id'] = BaseFieldDefinition::create('string');
 
     $fields['destination_path'] = BaseFieldDefinition::create('string')
       ->setLabel(t('Destination path'))