Trouble setting up field instance I have isolated my error to the field_create_instance($instance) line but can't make sense of what I'm doing wrong.  

function my_module_quote_add_qid() {
$field = array(
    'field_name' =&gt; 'qid',
    'type' =&gt; 'text',
  );
  field_create_field($field);
  $instance = array(
    'field_name' =&gt; 'qid',
    'entity_type' =&gt; 'node',
    'bundle' =&gt; 'product',
    'label' =&gt; t('qid'),
    'widget' =&gt; array(
      'type' =&gt; 'textfield',
    ),
  );
  field_create_instance($instance);
}

my_module_quote_add_qid();


This is what my error looks like:

Notice: Undefined index: view modes in EntityDefaultRulesController-&gt;eventInfo() (line 51 of /var/www/seven/sites/all/modules/entity/entity.rules.inc).
Notice: Undefined index: schema_fields_sql in DrupalDefaultEntityController-&gt;buildQuery() (line 265 of /var/www/seven/includes/entity.inc).
Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/www/seven/includes/entity.inc on line 284 and defined in SelectQuery-&gt;fields() (line 1300 of /var/www/seven/includes/database/select.inc).
SOLVED: 

According to the documentation, the only required properties are field_name, entity_type and bundle.  So I commented out:

'label' =&gt; t('qid'),
'widget' =&gt; array(
  'type' =&gt; 'textfield',
),


And now the field and instance install and uninstall properly.  I'm fairly sure 'textfield' is an inappropriate widget type.