Cannot create custom config entity fails because ID is blank I have created the following custom config entity. When I try to create a new one, I get the following error:

Drupal\Core\Entity\EntityMalformedException: The entity does not have an ID. in Drupal\Core\Config\Entity\ConfigEntityStorage-&gt;save() (line 248 of core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php).
Drupal\Core\Entity\Entity-&gt;save() (Line: 637)
Drupal\Core\Config\Entity\ConfigEntityBase-&gt;save() (Line: 151)


My understanding is that the entity system will create an ID for this entity, but it doesn't seem to be working in my case. I'm struggling to figure out what I need to change to get this work:

&lt;?php

namespace Drupal\example\Entity;

use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\example\Entity\ExampleConfigInterface;

/**
 * Defines the ExampleConfig entity.
 *
 * ExampleConfig config entities define a configuration for a specific
 * entity/bundle. Per entity settings are then saved as ExampleContent
 * entities.
 *
 * @ConfigEntityType(
 *   id = "example_config",
 *   label = @Translation("Example configuration"),
 *   fieldable = FALSE,
 *   handlers = {
 *     "list_builder" = "Drupal\example\ExampleConfigListBuilder",
 *     "form" = {
 *       "add" = "Drupal\example\Form\ExampleConfigForm",
 *       "edit" = "Drupal\example\Form\ExampleConfigForm",
 *       "delete" = "Drupal\example\Form\ExampleDeleteForm",
 *     }
 *   },
 *   config_prefix = "example",
 *   admin_permission = "administer site configuration",
 *   entity_keys = {
 *     "id" = "id",
 *     "example_entity_type" = "example_entity_type",
 *     "example_bundle" = "example_bundle",
 *   },
 *   links = {
 *     "edit-form" = "/admin/config/content/example/{example_config}",
 *     "delete-form" = "/admin/config/content/example/{example_config}/delete",
 *   }
 * )
 */
class ExampleConfig extends ConfigEntityBase implements ExampleConfigInterface {

  /**
   * The ID of the block.
   *
   * @var string
   */
  protected $id;

  protected $exampleEntityType;
  protected $exampleBundle;
  protected $exampleExpiry;
  protected $exampleDefaultStatus;

  /**
   * Get the bundle
   */
  public function getExampleBundle() {
    return $this-&gt;exampleBundle;
  }

  /**
   * Get the entity type.
   */
  public function getExampleEntityType() {
    return $this-&gt;exampleEntityType;
  }

  /**
   * Get the expiry time for this configuration.
   */
  public function getExampleExpiry() {
    if (!$this-&gt;exampleExpiry) {
      return example_expiry_default();
    }
    return $this-&gt;exampleExpiry;
  }

  /**
   * Get status for this configuration.
   */
  public function getExampleStatus() {
    return $this-&gt;exampleDefaultStatus;
  }

}


I have ended up prefixing all the custom properties to try to make sure I wasn't overriding something on accident. Even when the custom entity is blank, it still won't add.
My understanding is that the entity system will create an ID for this entity, but it doesn't seem to be working in my case. I'm struggling to figure out what I need to change to get this work:


That understanding is wrong. Config entities have machine names as ID's, you have to provide that. Most UI's generate one from the label, but that's form/UI code, the API has no such thing.