2 of 3 edited title

How add fields programmatically to a custom entity bundle?

i create a custom Entity,


public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);

    $fields['name'] = BaseFieldDefinition::create('string')
        'max_length' => 50,
        'text_processing' => 0,
      ->setDisplayOptions('view', [
        'label' => 'above',
        'type' => 'string',
        'weight' => -4,
      ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'weight' => -4,
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);

    return $fields;

We can add fields programmatically here for the Main entity and then all bundles ll automatically inherited fields from mother.

So i create a bundle in myModule/config/install:


uuid: db129d12-849a-4e68-bb56-d787b4b0cf42
langcode: en
status: true
dependencies: {  }
id: bundleA
label: bundleA

I am looking for add fields programmatically to that bundle .

So i create with the admin interface all fields and have export all config files into my install folder. But it's a lot of files: storage / view / field / form.

Is there another way like the main entity for example ?