diff --git entity/entity.api.php entity/entity.api.php
index 8ab1c4f..e0eb571 100644
--- entity/entity.api.php
+++ entity/entity.api.php
@@ -112,5 +112,42 @@ function entity_hook_entity_info() {
 }
 
 /**
+ * Act when exportable entities are enabled.
+ *
+ * This hook is invoked for exportable entities regardless of their export
+ * status as soon as new enabled entities are available to the system - either
+ * as a new entity has been saved to the database or modules with entities in
+ * code have been enabled.
+ *
+ * Note that there is no reliable way to react on configuration changes, as
+ * entities in code may be updated anytime.
+ *
+ * @param $entities
+ *   The entities keyed by entity ID.
+ * @param $entity_type
+ *   The type of entities being enabled (i.e. profile2_type, rules_config, ..).
+ */
+function hook_entity_enabled($entities, $entity_type) {
+  mymodule_initialize($entities, $entity_type);
+}
+
+/**
+ * Act when exportable entities are disabled.
+ *
+ * This hook is invoked for exportable entities regardless of their export
+ * status as soon as entities are unavailable to the system - either as an
+ * customly created entity has been deleted from the database or modules with
+ * entities in code have been disabled.
+ *
+ * @param $entities
+ *   The entities keyed by entity ID.
+ * @param $entity_type
+ *   The type of entities being disabled (i.e. profile2_type, rules_config, ..).
+ */
+function hook_entity_disabled($entities, $entity_type) {
+  mymodule_deactivate($entities, $entity_type);
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
diff --git entity/entity.controller.inc entity/entity.controller.inc
index b49be05..0d9cdf1 100644
--- entity/entity.controller.inc
+++ entity/entity.controller.inc
@@ -120,7 +120,7 @@ class EntityAPIController extends DrupalDefaultEntityController implements Entit
     parent::__construct($entityType);
     // Use the name key as primary identifier.
     $this->nameKey = isset($this->entityInfo['entity keys']['name']) ? $this->entityInfo['entity keys']['name'] : $this->idKey;
-    if (isset($this->entityInfo['exportable'])) {
+    if (!empty($this->entityInfo['exportable'])) {
       $this->entityInfo['entity keys'] += array('module' => 'module', 'status' => 'status');
       $this->statusKey = $this->entityInfo['entity keys']['status'];
       $this->moduleKey = $this->entityInfo['entity keys']['module'];
@@ -267,22 +267,17 @@ class EntityAPIController extends DrupalDefaultEntityController implements Entit
   protected function getDefaults($ids, $conditions = array()) {
     if (!isset($this->defaultEntities)) {
       $this->defaultEntities = array();
-      if (!empty($this->entityInfo['exportable'])) {
-        $this->entityInfo += array('export' => array());
-        $this->entityInfo['export'] += array('default hook' => 'default_' . $this->entityType);
-        if ($hook = $this->entityInfo['export']['default hook']) {
-          // Invoke the hook and collect default entities.
-          foreach (module_implements($hook) as $module) {
-            foreach ((array) module_invoke($module, $hook) as $id => $entity) {
-              $entity->{$this->statusKey} |= ENTITY_IN_CODE;
-              $entity->{$this->nameKey} = $id;
-              $entity->{$this->moduleKey} = $module;
-              $this->defaultEntities[$id] = $entity;
-            }
-          }
-          drupal_alter($hook, $this->defaultEntities);
+      $hook = isset($this->entityInfo['export']['default hook']) ? $this->entityInfo['export']['default hook'] : 'default_' . $this->entityType;
+      // Invoke the hook and collect default entities.
+      foreach (module_implements($hook) as $module) {
+        foreach ((array) module_invoke($module, $hook) as $id => $entity) {
+          $entity->{$this->statusKey} |= ENTITY_IN_CODE;
+          $entity->{$this->nameKey} = $id;
+          $entity->{$this->moduleKey} = $module;
+          $this->defaultEntities[$id] = $entity;
         }
       }
+      drupal_alter($hook, $this->defaultEntities);
     }
     $entities = is_array($ids) ? array_intersect_key($this->defaultEntities, array_flip($ids)) : $this->defaultEntities;
     if (!$this->defaultsFiltered && $conditions && $entities) {
@@ -382,8 +377,15 @@ class EntityAPIController extends DrupalDefaultEntityController implements Entit
         ->condition($this->nameKey, $ids, 'IN')
         ->execute();
 
-      foreach ($entities as $entity) {
+      foreach ($entities as $id => $entity) {
         $this->invoke('delete', $entity);
+        if (!empty($this->entityInfo['exportable']) && !($entity->{$this->statusKey} & ENTITY_IN_CODE)) {
+          $disabled_entities[$id] = $entity;
+        }
+      }
+      if (!empty($disabled_entities)) {
+        module_invoke_all($this->entityType . '_disabled', $disabled_entities);
+        module_invoke_all('entity_disabled', $disabled_entities, $this->entityType);
       }
       // Ignore slave server temporarily.
       db_ignore_slave();
@@ -415,6 +417,11 @@ class EntityAPIController extends DrupalDefaultEntityController implements Entit
         $return = drupal_write_record($this->entityInfo['base table'], $entity);
         $this->invoke('insert', $entity);
         unset($entity->is_new);
+        if (!empty($this->entityInfo['exportable']) && !entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
+          $entities = array($entity->{$this->nameKey} => $entity);
+          module_invoke_all($this->entityType . '_enabled', $entities);
+          module_invoke_all('entity_enabled', $entities, $this->entityType);
+        }
       }
       // Ignore slave server temporarily.
       db_ignore_slave();
diff --git entity/entity.module entity/entity.module
index 4b3e59c..0c95c9b 100644
--- entity/entity.module
+++ entity/entity.module
@@ -367,6 +367,66 @@ function entity_var_json_export($var, $prefix = '') {
 }
 
 /**
+ * Implements hook_modules_enabled().
+ *
+ * Invokes hook_entity_enabled() for new default entities.
+ */
+function entity_modules_enabled($modules) {
+  foreach (entity_crud_get_info() as $entity_type => $info) {
+    if (!empty($info['exportable']) && $entities = _entity_modules_get_defaults($entity_type, $modules)) {
+      module_invoke_all($entity_type . '_enabled', $entities);
+      module_invoke_all('entity_enabled', $entities, $entity_type);
+    }
+  }
+}
+
+/**
+ * Implements hook_modules_disabled().
+ *
+ * Invokes hook_entity_disabled() for new default entities.
+ */
+function entity_modules_disabled($modules) {
+  foreach (entity_crud_get_info() as $entity_type => $info) {
+    if (!empty($info['exportable']) && $entities = _entity_modules_get_defaults($entity_type, $modules)) {
+      module_invoke_all($entity_type . '_disabled', $entities);
+      module_invoke_all('entity_disabled', $entities, $entity_type);
+      // Make sure the cache is cleared afterwards, so removed default entities
+      // are not left there.
+      entity_get_controller($entity_type)->resetCache();
+    }
+  }
+}
+
+function _entity_modules_get_defaults($entity_type, $modules) {
+  $info = entity_get_info($entity_type);
+  $entities = array();
+  $hook = isset($info['export']['default hook']) ? $info['export']['default hook'] : 'default_' . $entity_type;
+  $module_key = isset($info['entity keys']['module']) ? $info['entity keys']['module'] : 'module';
+  // Collect the ids of all new entities.
+  foreach ($modules as $module) {
+    if (module_hook($module, $hook)) {
+      $result = module_invoke($module, $hook);
+      if ($result && is_array($result)) {
+        $entities += $result;
+      }
+    }
+  }
+  if ($ids = array_keys($entities)) {
+    // To make sure the new default entities are retrieved, make sure the cache
+    // is cleared.
+    entity_get_controller($entity_type)->resetCache();
+    // Check whether some of the new entities are already overridden.
+    $entities = array();
+    foreach (entity_load($entity_type, $ids) as $id => $entity) {
+      if (!entity_has_status($entity_type, $entity, ENTITY_OVERRIDDEN)) {
+        $entities[$id] = $entity;
+      }
+    }
+    return $entities;
+  }
+}
+
+/**
  * Implements hook_theme().
  */
 function entity_theme() {
diff --git entity/entity.test entity/entity.test
index 9e121dd..45b50cb 100644
--- entity/entity.test
+++ entity/entity.test
@@ -27,6 +27,8 @@ class EntityAPITestCase extends DrupalWebTestCase {
    * Tests CRUD.
    */
   function testCRUD() {
+    module_enable(array('entity_feature'));
+
     $user1 = $this->drupalCreateUser();
     // Create test entities for the user1 and unrelated to a user.
     $entity = new EntityClass(array('name' => 'test', 'uid' => $user1->uid));
@@ -62,6 +64,8 @@ class EntityAPITestCase extends DrupalWebTestCase {
    * Tests CRUD API functions: entity_(create|delete|save)
    */
   function testCRUDAPIfunctions() {
+    module_enable(array('entity_feature'));
+
     $user1 = $this->drupalCreateUser();
     // Create test entities for the user1 and unrelated to a user.
     $entity = entity_create('entity_test', array('name' => 'test', 'uid' => $user1->uid));
@@ -97,6 +101,8 @@ class EntityAPITestCase extends DrupalWebTestCase {
    * Test loading entities defined in code.
    */
   function testExportables() {
+    module_enable(array('entity_feature'));
+
     $types = entity_load('entity_test_type', array('test', 'test2'));
     $this->assertEqual($types['test']->label, 'label', 'Default type loaded.');
     $this->assertTrue($types['test']->status & ENTITY_IN_CODE && !($types['test']->status & ENTITY_IN_DB), 'Default type status is correct.');
@@ -140,9 +146,62 @@ class EntityAPITestCase extends DrupalWebTestCase {
   }
 
   /**
+   * Tests hook_entity_enabled() and hook_entity_disabled().
+   */
+  function testExportablesActivation() {
+    $_SESSION['entity_hook_test'] = array();
+    // Enabling the module should invoke the enabled hook for the other
+    // entities provided in code.
+    module_enable(array('entity_feature'));
+
+    $all = array('main', 'test', 'test2');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_enabled'] == array($all), 'Hook entity_enabled has been invoked.');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_test_type_enabled'] == array($all), 'Hook entity_test_type_enabled has been invoked.');
+
+    // Add a new test entity in DB and make sure the hook is invoked too.
+    $test3 = new EntityDB(array(
+      'name' => 'test3',
+      'label' => 'label',
+      'weight' => 0,
+    ), 'entity_test_type');
+    $test3->save();
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_enabled'] == array($all, array('test3')), 'Hook entity_enabled has been invoked.');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_test_type_enabled'] == array($all, array('test3')), 'Hook entity_test_type_enabled has been invoked.');
+
+    // Now override the 'test' entity and make sure it doesn't invoke the
+    // enabling hook as it is already enabled. Then make sure it stays enabled
+    // when the feature module is disabled.
+    $result = entity_load('entity_test_type', array('test'));
+    $result['test']->label = 'modified';
+    $result['test']->save();
+
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_enabled'] == array($all, array('test3')), 'Hook entity_enabled has been invoked.');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_test_type_enabled'] == array($all, array('test3')), 'Hook entity_test_type_enabled has been invoked.');
+
+    // 'test' has to remain enabled, as it has been overridden.
+    $all = array('main', 'test2');
+    module_disable(array('entity_feature'));
+
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_disabled'] == array($all), 'Hook entity_disabled has been invoked.');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_test_type_disabled'] == array($all), 'Hook entity_test_type_disabled has been invoked.');
+
+    // Now make sure 'test' is not overridden any more, but custom.
+    $result = entity_load('entity_test_type', array('test'));
+    $this->assertTrue(!entity_has_status('entity_test_type', $result['test'], ENTITY_OVERRIDDEN), 'Entity is not marked as overridden any more.');
+
+    // Test disabled hook for deleting the remaining entities from DB.
+    entity_delete_multiple('entity_test_type', array('test', 'test3'));
+    $all2 = array('test', 'test3');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_disabled'] == array($all, $all2), 'Hook entity_disabled has been invoked.');
+    $this->assertTrue($_SESSION['entity_hook_test']['entity_test_type_disabled'] == array($all, $all2), 'Hook entity_test_type_disabled has been invoked.');
+  }
+
+  /**
    * Tests viewing entites.
    */
   function testRendering() {
+    module_enable(array('entity_feature'));
+
     $user1 = $this->drupalCreateUser();
     // Create test entities for the user1 and unrelated to a user.
     $entity = entity_create('entity_test', array('name' => 'test', 'uid' => $user1->uid));
diff --git entity/tests/entity_feature.info entity/tests/entity_feature.info
new file mode 100644
index 0000000..70c9f56
--- /dev/null
+++ entity/tests/entity_feature.info
@@ -0,0 +1,8 @@
+; $Id$
+name = Entity feature module
+description = Provides some entities in code.
+version = VERSION
+core = 7.x
+files[] = entity_feature.module
+dependencies[] = entity_test
+hidden = TRUE
diff --git entity/tests/entity_feature.module entity/tests/entity_feature.module
new file mode 100644
index 0000000..26caa8f
--- /dev/null
+++ entity/tests/entity_feature.module
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Test module providing some entities in code.
+ */
+
+/**
+ * Implements hook_default_entity_test_type().
+ */
+function entity_feature_default_entity_test_type() {
+  $types['main'] = new EntityDB(array(
+      'name' => 'main',
+      'label' => t('Main test type'),
+      'weight' => 0,
+      'locked' => TRUE,
+  ), 'entity_test_type');
+
+  // Types used during CRUD testing.
+  $types['test'] = new EntityDB(array(
+    'name' => 'test',
+    'label' => 'label',
+    'weight' => 0,
+  ), 'entity_test_type');
+  $types['test2'] = new EntityDB(array(
+      'name' => 'test2',
+      'label' => 'label2',
+      'weight' => 2,
+  ), 'entity_test_type');
+
+  return $types;
+}
diff --git entity/tests/entity_test.module entity/tests/entity_test.module
index 553372a..1e30697 100644
--- entity/tests/entity_test.module
+++ entity/tests/entity_test.module
@@ -106,33 +106,6 @@ function entity_test_entity_test_type_presave($type) {
   $type->data = $data;
 }
 
-
-/**
- * Implement hook_default_entity_test_type().
- */
-function entity_test_default_entity_test_type() {
-  $types['main'] = new EntityDB(array(
-      'name' => 'main',
-      'label' => t('Main test type'),
-      'weight' => 0,
-      'locked' => TRUE,
-  ), 'entity_test_type');
-
-  // Types used during CRUD testing.
-  $types['test'] = new EntityDB(array(
-    'name' => 'test',
-    'label' => 'label',
-    'weight' => 0,
-  ), 'entity_test_type');
-  $types['test2'] = new EntityDB(array(
-      'name' => 'test2',
-      'label' => 'label2',
-      'weight' => 2,
-  ), 'entity_test_type');
-
-  return $types;
-}
-
 /**
  * Main class for test entities.
  */
@@ -152,3 +125,31 @@ class EntityClass extends EntityDBExtendable {
     return entity_get_controller($this->entityType)->buildContent($this, $view_mode, $langcode, $content);
   }
 }
+
+/**
+ * Implements hook_entity_enabled().
+ */
+function entity_test_entity_enabled($entities) {
+  $_SESSION['entity_hook_test']['entity_enabled'][] = array_keys($entities);
+}
+
+/**
+ * Implements hook_entity_disabled().
+ */
+function entity_test_entity_disabled($entities) {
+  $_SESSION['entity_hook_test']['entity_disabled'][] = array_keys($entities);
+}
+
+/**
+ * Implements hook_entity_test_type_enabled().
+ */
+function entity_test_entity_test_type_enabled($entities) {
+  $_SESSION['entity_hook_test']['entity_test_type_enabled'][] = array_keys($entities);
+}
+
+/**
+ * Implements hook_entity_test_type_disabled().
+ */
+function entity_test_entity_test_type_disabled($entities) {
+  $_SESSION['entity_hook_test']['entity_test_type_disabled'][] = array_keys($entities);
+}
