Add a non-base field to a content entity form What is the proper way to add a non-base textarea field to the entity form of a custom content entity?

comment and user modules have non-base fields that display in their entity form (comment_body and picture), but it appears these fields are added to the form somewhere besides the main entity form method they use.

In my module, I've created a field and instance inside hook_install like this:

&lt;?php
function mymodule_install() {
  $field = array(
    'name' =&gt; 'myfield',
    'entity_type' =&gt; 'myentitytype',
    'type' =&gt; 'text_long',
    'module' =&gt; 'text',
    'settings' =&gt; array(),
    'cardinality' =&gt; 1,
    'locked' =&gt; FALSE,
    'indexes' =&gt; array(),
  );
  entity_create('field_entity', $field)-&gt;save();

  $instance = array(
    'field_name' =&gt; 'myfield',
    'entity_type' =&gt; 'myentitytype',
    'bundle' =&gt; 'myentitytype',
    'label' =&gt; 'Field title',
    'description' =&gt; t('Field description.'),
    'required' =&gt; TRUE,
    'default_value' =&gt; array(),
    'settings' =&gt; array(
      'text_processing' =&gt; '0'
    ),
  );
  entity_create('field_instance', $instance)-&gt;save();
}


I think if I could be pointed to how comment_body gets added to the comment entity form, or picture to the user entity form, I'd be able to resolve this.
You can ship a locked Field with yml only, see core/modules/forum/config/field.*. Ie just make the fields in the ui and copy the yml files from your active store to a config folder inside your module. 

This ships a locked boolean field for the container flag. You'll also need form and entity display entities, but you can create them in the ui and grab the yml for them too.