How to retrieve ConfigEntity instance from config factory? I have defined a config entity in my module (schema and class that extends ConfigEntityBase) - MyConfigEntity.

When I use config factory to get config, Drupal returns instance of Config or ImmutableConfig. How can I retrieve instance of MyConfigEntity instead?

$config = \Drupal::config('my_module.config.something');
// Now $config is instance of ImmutableConfig.
\Drupal::config()


  Retrieves a configuration object.
  
  This is the main entry point to the configuration API. 


The configuration API is a different system than the entity API.

$entity = \Drupal::entityTypeManager()
  -&gt;getStorage('my_config_entity')
  -&gt;load($id);


Configuration entity types should be used to store configurable content like content types or other site builder-esque things that you want to deploy from environment to environment that is not managed content (Something a content author would write).

If you're looking for a complex configuration object, then you should define that in config/mymodule.settings.yml and use the configuration API like in your question.