diff --git entity_example/entity_example.info entity_example/entity_example.info
new file mode 100644
index 0000000..66d9987
--- /dev/null
+++ entity_example/entity_example.info
@@ -0,0 +1,5 @@
+name = entity example
+description = entity example
+core = 7.x
+package = Example modules 
+files[] = entity_example.test
diff --git entity_example/entity_example.install entity_example/entity_example.install
new file mode 100644
index 0000000..32e371c
--- /dev/null
+++ entity_example/entity_example.install
@@ -0,0 +1,40 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * entity base table schema
+ */
+function entity_example_schema() {
+  $schema['person'] = array(
+    'fields' => array(
+      'person_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'personality' => array(
+        'type' => 'text',
+        'size' => 'medium',
+        'description' => 'the bundle property',
+        'not null' => TRUE
+      ),
+      'name' => array(
+        'type' => 'text',
+        'size' => 'medium'
+      )
+    ),
+    'primary key' => array('person_id')
+  );
+  return $schema;
+}
+/*
+ * there is a bug in drupal , where field_info_field does function properly during module uninstall
+ * so the below hook_uninstall is futile
+ */
+/*
+function entity_example_uninstall(){
+  field_attach_delete_bundle( 'person' , 'teacher' );
+  field_attach_delete_bundle( 'person' , 'student' );
+}
+*/
diff --git entity_example/entity_example.module entity_example/entity_example.module
new file mode 100644
index 0000000..c36a5c1
--- /dev/null
+++ entity_example/entity_example.module
@@ -0,0 +1,154 @@
+<?php
+/*
+ * hook_entity_info
+ */
+function entity_example_entity_info() {
+  $person = array(
+    'label' => t('person'),
+    'base table' => 'person',
+    'uri callback' => 'entity_example_personuri',
+    'fieldable' => TRUE,
+    'entity keys' => array( 'id' => 'person_id' , 'bundle' => 'personality'),
+    'bundle keys' => array( 'bundle' => 'personality' ),
+    'bundles' => array()
+  );
+  $person['bundles']['teacher'] = array(
+    'label' => t('Teacher'),
+    'admin' => array(
+      'path' => 'admin/person/%personality',
+      'real path' => 'admin/person/teacher',
+      'bundle argument' => 2,
+      'access arguments' => array('administer people')
+    )
+  );
+  $person['bundles']['student'] = array(
+    'label' => t('Student'),
+    'admin' => array(
+      'path' => 'admin/person/%personality',
+      'real path' => 'admin/person/student',
+      'bundle argument' => 2,
+      'access arguments' => array('administer people')
+    )
+  );
+  $entities = array(
+    'person' => $person
+  );
+  return $entities;
+}
+
+function entity_example_menu() {
+  $items = array();
+  // pages to view and edit person
+  $items += entity_example_menu_person();
+  // pages to admin person entity and create persons
+  $items += entity_example_menu_admin_person();
+  return $items;
+}
+
+function entity_example_menu_person() {
+  // lists all persons
+  // appears under site navigation menu
+  $items['examples/person'] = array(
+    'title' => 'person list',
+    'access arguments' => array('access content'),
+    'page callback' => 'entity_example_person_list',
+    'file' => 'entity_example.pages.inc',
+    'type' => MENU_NORMAL_ITEM
+  );
+  // single person page
+  // see person_load to see how %person is loaded
+  $items['examples/person/%person'] = array(
+    'title callback' => 'entity_example_person_title',
+    'title arguments' => array(2),
+    'page callback' => 'entity_example_person',
+    'page arguments' => array(2),
+    'access arguments' => array('access content'),
+    'file' => 'entity_example.pages.inc',
+    'type' => MENU_CALLBACK
+  );
+  // view tab
+  $items['examples/person/%person/view'] = array(
+    'title' => 'view',
+    'access arguments' => array('access content'),
+    'weight' => -3,
+    'type' => MENU_DEFAULT_LOCAL_TASK
+  );
+  // edit tab
+  $items['examples/person/%person/edit'] = array(
+    'title' => 'edit',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array( 'entity_example_person_edit' , 2 ),
+    'access arguments' => array('access content'),
+    'file' => 'entity_example.pages.inc',
+    'type' => MENU_LOCAL_TASK
+  );
+  return $items;
+}
+
+function entity_example_menu_admin_person() {
+// list personalities 
+// appears under administration toolbar 
+  $items['admin/person'] = array(
+    'title' => 'admin person',
+    'access arguments' => array('access content'),
+    'page callback' => 'entity_example_person_admin',
+    'file' => 'entity_example.pages.inc',
+    'type' => MENU_NORMAL_ITEM
+  );
+  // personality admin page , used by field attach api
+  // see personality_load to see how %personality is loaded
+  $items['admin/person/%personality'] = array(
+    'title callback' => 'entity_example_personality_title',
+    'title arguments' => array(2),
+    'access arguments' => array('access content'),
+    'page arguments' => array(2),
+  );
+  // personality default tab : create a person
+  $items['admin/person/%personality/add'] = array(
+    'title' => 'add',
+    'access arguments' => array('access content'),
+    'type' => MENU_DEFAULT_LOCAL_TASK
+  );
+  return $items;
+}
+/*
+ * argument loader for %person
+ */
+function person_load($id) {
+  $persons = entity_load( 'person' , array($id) );
+  return $persons[$id];
+}
+/*
+ * argument loader for %personality
+ * makes sure no xss is used thourgh the personality property
+ */
+function personality_load($personality) {
+  switch ($personality) {
+  case 'teacher':
+  case 'student':
+    return $personality; 
+  default:
+    return FALSE;
+  }
+}
+function entity_example_personality_title( $personality ) {
+  return $personality;
+}
+function entity_example_person_title( $person ) {
+  return $person->name;
+}
+function entity_example_personuri($person) {
+  return array( 'path' => 'person/' . $person->person_id );
+}  
+
+
+
+/**
+ * Implements hook_help().
+ */
+function entity_example_help($path, $arg) {
+  switch ($path) {
+    case 'admin/help#entity_example':
+      return "<p>" . t('entity example implements person entity that has teacher,student bundles , and it adds administration page under "person admin"') . "</p>";
+  }
+}
diff --git entity_example/entity_example.pages.inc entity_example/entity_example.pages.inc
new file mode 100644
index 0000000..2151c3f
--- /dev/null
+++ entity_example/entity_example.pages.inc
@@ -0,0 +1,164 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * entity example persons pages and administration forms
+ */
+
+/*
+ * list persons
+ */
+function entity_example_person_list() {
+  $results = db_select('person' , 'p')->fields('p')->execute();
+  $persons = array();
+  foreach ( $results as $record ) {
+    $persons[ $record->person_id ] = $record;
+  }
+  // calling attach_load on array is more effiecient than inside the above loop
+  field_attach_load( 'person' , $persons );
+  $content = array();
+  foreach ( $persons as $person ) {
+    $content[] = array(
+      '#markup' => l( "$person->personality: $person->name" , 'examples/person/' . $person->person_id )
+    );
+    $content[] = field_attach_view( 'person' , $person , 'full' );
+  }
+  return $content;
+}
+/*
+ * view a person
+ */
+function entity_example_person( $person ) {
+  $content[] = array(
+    '#markup' => l( $person->name , 'examples/person/' . $person->person_id )
+  );
+  $content[] = field_attach_view( 'person' , $person , 'full' );
+  return $content;
+}
+/*
+ * person administration
+ */
+function entity_example_person_admin($personality = NULL) {
+  if ($personality) {
+    return drupal_get_form( 'entity_example_addperson' , $personality );
+  }
+  else{
+    $rows = array();
+    $rows[] = array( l( t('teacher') , 'admin/person/teacher' ) );
+    $rows[] = array( l( t('student') , 'admin/person/student' ) );
+    $header =  array( 'links' );
+    $output = theme( 'table' , array('header' => $header , 'rows' => $rows) );
+  }
+  $content[] = array( '#markup' => $output );
+  return $content;
+}
+
+/*
+ * create a new person
+ */
+function entity_example_addperson($form , &$form_state , $personality) {
+  $form['name'] = array(
+    '#type' => 'textfield',
+    '#title' => 'name'
+  );
+
+  $person = new stdClass();
+  $person->personality = $personality;
+  $person->id = 0;
+
+  $form['person'] = array(
+    '#type' => 'value',
+    '#value' => $person
+  );
+  // validations requires is element
+  $form['personality'] = array(
+    '#type' => 'value',
+    '#value' => $personality
+  );
+  // attach form elements for attached fields
+  field_attach_form( 'person' , $person , $form , $form_state );
+  
+  $form['actions'] = array('#type' => 'actions');
+  $form['actions']['add'] = array(
+    '#type' => 'submit',
+    '#value' => 'add'
+  );
+  return $form;
+}
+function entity_example_addperson_validate( $form , &$form_state ) {
+  entity_form_field_validate( 'person' , $form , $form_state );
+}
+function entity_example_addperson_submit( $form , &$form_state ) {
+  $person = $form_state['values']['person'];
+  $person->name = check_plain( $form_state['values']['name'] );
+  drupal_write_record( 'person' , $person );
+  entity_form_submit_build_entity( 'person' , $person , $form , $form_state );
+  field_attach_submit( 'person' , $person , $form , $form_state );
+  // insert fields
+  field_attach_insert( 'person' , $person );
+
+  drupal_set_message( 
+    t( 'new @personality got added' , 
+    array('@personality' => $person->personality) ) 
+  );
+}
+
+/*
+ * edit an existing person
+ */
+function entity_example_person_edit($form , &$form_state , $person) {
+  $form['name'] = array(
+    '#type' => 'textfield',
+    '#title' => 'name',
+    '#default_value' => $person->name
+  );
+
+  $form['person'] = array(
+    '#type' => 'value',
+    '#value' => $person
+  );
+  $form['personality'] = array(
+    '#type' => 'value',
+    '#value' => $person->personality
+  );
+  field_attach_form( 'person' , $person , $form , $form_state );
+
+  $form['actions'] = array('#type' => 'actions');
+  $form['actions']['save'] = array(
+    '#type' => 'submit',
+    '#value' => 'save'
+  );
+  $form['actions']['delete'] = array(
+    '#type' => 'submit',
+    '#value' => 'delete',
+    '#submit' => array('entity_example_person_edit_delete')
+  );
+  return $form;
+}
+function entity_example_person_edit_validate( $form , &$form_state ) {
+  entity_form_field_validate( 'person' , $form , $form_state );
+}
+function entity_example_person_edit_submit( $form , &$form_state ) {
+  $person = $form_state['values']['person'];
+  $person->name = check_plain( $form_state['values']['name'] );
+  drupal_write_record( 'person' , $person , array('person_id') );
+  entity_form_submit_build_entity( 'person' , $person , $form , $form_state );
+  field_attach_submit( 'person' , $person , $form , $form_state );
+  // update fields
+  field_attach_update( 'person' , $person );
+
+  drupal_set_message( 
+    t( 'the $personality got saved' , 
+    array('@personality' => $person->personality) ) 
+  );
+  $form_state['redirect'] = 'examples/person/' . $person->person_id;
+}
+function entity_example_person_edit_delete( $form , &$form_state ) {
+  $person = $form_state['values']['person'];
+  field_attach_delete( 'person' , $person );
+  db_delete('person')
+    ->condition( 'person_id' , $person->person_id , '=' )
+    ->execute();
+  $form_state['redirect'] = 'examples/person';
+}
diff --git entity_example/entity_example.test entity_example/entity_example.test
new file mode 100644
index 0000000..2af2102
--- /dev/null
+++ entity_example/entity_example.test
@@ -0,0 +1,65 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Simpletest case for entity_example module.
+ *
+ * Verify example module functionality.
+ */
+
+/**
+ * Functionality tests for node example module.
+ */
+class EntityExampleTestCase extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Entity example',
+      'description' => 'test attaching field',
+      'group' => 'Examples',
+    );
+  }
+
+  function setUp() {
+    // Enable the module.
+    parent::setUp('entity_example');
+    $field = array(
+      'field_name' => 'test_lastname' , 
+      'type' => 'text'
+    );
+    field_create_field($field);
+    $field = array(
+      'label' => 'last name',
+      'field_name' => 'test_lastname',
+      'entity_type' => 'person',
+      'bundle' => 'teacher'
+    );
+    field_create_instance($field);
+  }
+
+  /**
+   * 
+   */
+  function testFieldAttachment() {
+    // Create and login user.
+    $account = $this->drupalCreateUser(array('access content'));
+    $this->drupalLogin($account);
+
+    $edit = array(
+      'name' => 'firstname',
+      'test_lastname[und][0][value]' => 'lastname',
+    );
+    $this->drupalPost('admin/person/teacher' , $edit, 'add');
+    $this->assertText('new teacher got added' , 'teacher addition message is shown');
+    
+    // view persons list page 
+    $this->drupalGet('examples/person');
+    $this->assertText('teacher: first' , 'personality and name is shown');
+    $this->assertText('lastname' , 'lastname field value is shown');
+    // view person page 
+    $this->drupalGet('examples/person/1');
+    $this->assertText('lastname' , 'last name got saved');
+  }
+}
+
