diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
index a4dc772..fd0cf49 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
@@ -1057,7 +1057,7 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam
         // SQL database drivers.
         // @see https://www.drupal.org/node/2279395
         $value = drupal_schema_get_field_value($definition->getSchema()['columns'][$column_name], $value);
-        if (!(empty($value) && $this->getSchema()[$table_name]['fields'][$schema_name]['type'] == 'serial')) {
+        if (!empty($value) || !$this->isColumnSerial($table_name, $schema_name)) {
           $record->$schema_name = $value;
         }
       }
@@ -1067,6 +1067,33 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam
   }
 
   /**
+   * Checks whether a field column should be treated as serial.
+   *
+   * @param $table_name
+   *   The name of the table the field column belongs to.
+   * @param $schema_name
+   *   The schema name of the field column.
+   *
+   * @return bool
+   *   TRUE if the the column is serial, FALSE otherwise.
+   */
+  protected function isColumnSerial($table_name, $schema_name) {
+    $result = FALSE;
+
+    switch ($table_name) {
+      case $this->baseTable:
+        $result = $schema_name == $this->idKey;
+        break;
+
+      case $this->revisionTable:
+        $result = $schema_name == $this->revisionKey;
+        break;
+    }
+
+    return $result;
+  }
+
+  /**
    * Maps from an entity object to the storage record of the field data.
    *
    * @param \Drupal\Core\Entity\EntityInterface $entity
