Add properties to an entity hook_schema_alter I need to implement a custom module that adds fields and properties to an entity defined in another module. I felt the best way to do this was using hook_schema_alter and hook_update_n to achieve the data structure updates. However, I do not see these new fields on my entity. Is there another step to take to attach these to the entity via code?
Using the third-party Entity API module, you can:


Implement hook_schema_alter().
Use something like db_add_field() to actually make the change to the DB in YOURMODULE_install() or updateN(). hook_schema_alter() does not actually create the field in the database. It just tells other modules at the code level that the field exists in the schema.
Implement hook_entity_property_info_alter(). This tells the Entity API module that this field exists as a property of some entity, where it lives in the database table, and how to access it.

Clear the cache to have the new properties showing up.



An example property in the $info array is basically the following one:

  $properties['survey_count_to_complete'] = array(
    'label' =&gt; t('Number of Surveys to Complete'),
    'type' =&gt; 'integer',
    'description' =&gt; 'When a student logs in the system derives how many surveys they must complete. We store this value to make business logic easier.',
    // This is the schema field you made.
    'schema field' =&gt; 'survey_count_to_complete',
    'getter callback' =&gt; 'entity_property_verbatim_get',
    'setter callback' =&gt; 'entity_property_verbatim_set',
  );