How to create one entity and assign the same entity as field to new entity programatically -I need to create one entity (need to do coding)- that I created already, now want to create  another entity, lets say "Entity 2"( term(taxonomy, param1, param2, description( it will have multiple values- multiple description). 
Now I need to add entity 2 as field for entity 1. Entity 1 can have multiple entities of type "Entity 2"
Once you have the ID of the new entities, it's as simple as:

$new_entity-&gt;field_foo[LANGUAGE_NONE][0]['target_id'] = $other_entity_id;
$new_entity-&gt;field_foo[LANGUAGE_NONE][1]['target_id'] = $yet_another_entity_id;


I've assumed the field type is Entity Reference, YMMV for other types.