Newly created field not being added to entity I have created a form that adds a subset of field types to an entity (does not support bundles).  (the reason for the custom form is that end users find the Drupal standard 'Manage fields' workflow too difficult)  The class extends FormBase.  When the 'submitForm' function is executed, the field is saved but not added to the entity.
This is the code to save a date field (with text values filled in for explanation purposes):
$field_storage_values = [
  'field_name' =&gt; 'field_test_date',
  'entity_type' =&gt; 'my_entity_id',
  'type' =&gt; 'datetime',
  'translatable' =&gt; TRUE,
];

$field_values = [
  'field_name' =&gt; 'field_test_date',
  'entity_type' =&gt; 'my_entity_id',
  'bundle' =&gt; 'my_entity_id',
  'label' =&gt; 'Test Date',
  'translatable' =&gt; FALSE,
];

$this-&gt;entityTypeManager-&gt;getStorage('field_storage_config')-&gt;create($field_storage_values)-&gt;save();
$field = $this-&gt;entityTypeManager-&gt;getStorage('field_config')-&gt;create($field_values);
$field-&gt;save();

When the form is submitted, the field is created correctly but not added to the entity.
When I export the field configuration to YML, the following appears under dependencies:
dependencies:
  config:
    - field.storage.my_entity_id.field_test_date

Creating an identical Node field results in the following field configuration YML dependencies:
dependencies:
  config:
    - field.storage.node.field_test_date
    - node.type.basic_page

I suspect the field created with my custom form should also add the second configuration dependency like:
my_entity_id.type.my_entity_id

I tried adding the following before the field is saved but the 'addDependency' function is protected.
$field-&gt;addDependency('config', 'my_entity_id.type.my_entity_id');
You can't add this dependency, it's bundle configuration which you don't have and don't need in a bundleless entity. For testing better add a user instead of a node field or check the already pre-installed field.field.user.user.user_picture.yml
To create the field config you only need to specifiy the field storage and the bundle (for a bundleless entity this is the entity id). The other values are then extracted from the storage config:
$storage = $this-&gt;entityTypeManager-&gt;getStorage('field_storage_config')-&gt;create($field_storage_values);
$storage-&gt;save();

$field = $this-&gt;entityTypeManager-&gt;getStorage('field_config')-&gt;create([
  'field_storage' =&gt; $storage,
  'bundle' =&gt; 'my_entity_id',
]);
$field-&gt;save();

BTW part of the field UI is also the configuration of display modes. You need to add the new field as component at least to the default view and form mode, so that the new field is visible. See How to change the entity view display configuration programmatically?