I have created an entity via custom module. This entity does not have any bundle and it gets created perfectly fine. entity_get_info says it is not necessary to have bundles.
Next, I create a field for entity reference using field_create_field and that works fine too. Now, when i want to associate this field as an instance to my custom entity and when I call field_create_instance (without specifying bundle), I get the error saying:
drupal FieldException: Attempt to create an instance of field without a bundle
I go on to see that bundle is a required field in field_config_instance .. I tried to specify bundle as the same name as entity but that did not work for me either. Actually, it did create an instance but on the entity add/edit form when I do a field_attach_form, I get another error:
Notice: Undefined index: target_bundles in EntityReferenceHandler_base->buildEntityFieldQuery() (line 174 of /Applications/MAMP/htdocs/MYPROJECT/sites/all/modules/entityreference/handler/base.inc).
Any help will be highly appreciated.