How do I programmatically insert the entity ID? I have added extra fields on the drupal 7 user registration form and created a module with a hook_form_alter function so that i can alter one field in the registration form. 
in the same file i also added the hook_form_submit function to handle the submission of that input box.

function user_registration_form_alter(&amp;$form, &amp;$form_state, $form_id){
if ($form_id == 'user_register_form'){

    $form['field_first_name'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('First Name'),
        '#description' =&gt; t('Enter your first name.'),
        '#maxlength' =&gt; 255,
        '#required' =&gt; TRUE,
        );


}

if (isset($form['actions']['submit'])) {
        $form['actions']['submit']['#submit'][] = 'user_registration_form_submit';
       }
}


function user_registration_form_submit(&amp;$form, &amp;$form_state)
    {
        $fe_id = db_insert('field_revision_field_first_name')
        -&gt;fields(array(
            'field_first_name_value' =&gt; $form_state['values']['field_first_name'],
            ))-&gt;execute();
        drupal_set_message(t('your form entry has been added'));
    }


When i click on the submit button i get the following error message


  PDOException: SQLSTATE[HY000]: General error: 1364 Field 'entity_id' doesn't have a default value: INSERT INTO {field_revision_field_first_name} (field_first_name_value) VALUES (:db_insert_placeholder_0); Array ( [:db_insert_placeholder_0] => john ) in user_registration_form_submit() (line 38 of /var/www/html/lite/sites/all/modules/user_regestration/user_registration.module)‌​‌​


I noticed the error is generated because the"entity_id doesn't have a default value" when the insert query is executed. 
My question is how do i include the entity_id default value.
Why don't you use a module providing this functionality, like profile2 ?

The user is not created in your submithandler, so either you save it:

function foo_user_register_form_submit($form, &amp;$form_state){
    $edit = array(
          'name' =&gt; $form_state['values']['name'], 
          'pass' =&gt; user_password(),
          'mail' =&gt; $form_state['values']['mail'],
          'init' =&gt; $form_state['values']['mail'], 
          'status' =&gt; 1, 
          'access' =&gt; REQUEST_TIME,
          'field_first_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; $form_state['values']['field_first_name']))),
    );
    user_save(drupal_anonymous_user(), $edit);
}


For more details see the docs.

Or you could try to add a custom submit handler, which would be fired after the user is created, in form_alter:

$form['#submit'][] = 'your_custom_submit_handler_function';


In there the user should already be created. so:

function your_custom_submit_handler_function(&amp;$form, &amp;$form_state)
    {
        $fe_id = db_insert('field_revision_field_first_name')
        -&gt;fields(array(
            'field_first_name_value' =&gt; $form_state['values']['field_first_name'],
            ))-&gt;execute();
        drupal_set_message(t('your form entry has been added'));
    }



  But keep in mind, that this custom inserting maybe needs some more
  code, here you only add the revision entry ..