How to Auto-save a custom entity to database in response to a new user account using Rules? I have defined new custom entity through hook_entity_info:

function mymodule_entity_info(){
  return array(
    'mymodule_account' =&gt; array(
      'label' =&gt; 'MyModule Account',
      'entity class' =&gt; 'MymoduleAccount',
      'controller class' =&gt; 'EntityAPIController',
      'views controller class' =&gt; 'EntityDefaultViewsController',
      'base table' =&gt; 'mymodule_accounts',
      'entity keys' =&gt; array(
        'id' =&gt; 'aid',
      ),
      'fieldable' =&gt; TRUE,
      'load hook' =&gt; 'mymodule_account_load',
      'view modes' =&gt; array(
        'full' =&gt; array('label' =&gt; 'Full', 'custom settings' =&gt; FALSE),
        'teaser' =&gt; array('label' =&gt; 'Teaser', 'custom settings' =&gt; FALSE),
      ),
    ),

  );
}


I have extended the Entity class, overriding the constructor:

class MymoduleAccount extends Entity{

  public function __construct(array $values = array(), $entityType = 
  'mymodule_account'){

    global $user;
    if(empty($values)){
      $values['created'] = REQUEST_TIME;
      $values['title'] = '';
      $values['balance'] = 0.00;
      $values['uid'] = $user-&gt;uid;
    }

    $this-&gt;entityType = $entityType;
    $this-&gt;setUp();
    // Set initial values.
    foreach ($values as $key =&gt; $value) {
      $this-&gt;$key = $value;
    }
  }
}


I have defined a reaction-rule as follows:

On events segment: I selected

After saving a new user account


On actions segment: I defined two elements:

Create a new entity
Parameter: Entity type: Mymodule Account
Provides variables: Created entity (entity_created)


And:

Save entity
Parameter: Entity: [entity-created], Force saving immediately: true


I have tested these codes by creating new user account, but no mymodule_account has been created in it's database table. What am I missing?
Your issue (about "no account has been created in DB table") might possibly be because of the event (= "after saving new user account") you are using, which might simply not be the right event.

Moreover, have a look at issue # 430274, about an event which is a variation of your event here, and somehow explains that "after saving something" actually happens ... "before saving something" (which is not a bug, simply how the Rules module  works ...).

A possible compromise to avoid these kind of issues, is to transform what's you're trying to do into a Rules Component, so that your original Rule "schedules the execution" (using the Rules Scheduler submodule) of that Rules Component (eg X secs or mins "after saving that new user account" ... if your cron job runs frequent enough, if not it'll be next time cron runs). This compromise will ensure that at the time the Rules Component is executed, the content is for sure saved ... (so that can't be the reason anymore then why it would still be empty ...).

Not sure if this is "the" reason for your issue, but I'd definitely give it a try to see if it helps (debugging is the art of taking away all possible causes for an issue ...).