diff --git a/core/modules/taxonomy/taxonomy.entity.inc b/core/modules/taxonomy/taxonomy.entity.inc
index 3562580..41ea965 100644
--- a/core/modules/taxonomy/taxonomy.entity.inc
+++ b/core/modules/taxonomy/taxonomy.entity.inc
@@ -110,8 +110,13 @@ class TaxonomyTermController extends EntityDatabaseStorageController {
     // @todo Move to TaxonomyTerm::bundle() once field API has been converted
     // to make use of it.
     if (!isset($entity->vocabulary_machine_name)) {
-      $vocabulary = taxonomy_vocabulary_load($entity->vid);
-      $entity->vocabulary_machine_name = $vocabulary->machine_name;
+      if (isset($entity->vid)) {
+        $vocabulary = taxonomy_vocabulary_load($entity->vid);
+        $entity->vocabulary_machine_name = $vocabulary->machine_name;
+      }
+      elseif (isset($entity->tid) && $term = taxonomy_term_load($entity->tid)) {
+        $entity->vocabulary_machine_name = $term->vocabulary_machine_name;
+      }
     }
     // Save new terms with no parents by default.
     if (!isset($entity->parent)) {
diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test
index 5c16884..d574a20 100644
--- a/core/modules/taxonomy/taxonomy.test
+++ b/core/modules/taxonomy/taxonomy.test
@@ -1913,3 +1913,40 @@ class TaxonomyThemeTestCase extends TaxonomyWebTestCase {
   }
 
 }
+
+/**
+ * Tests the functionality of EntityFieldQuery for taxonomy entities.
+ */
+class TaxonomyEFQTestCase extends TaxonomyWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Taxonomy EntityFieldQuery',
+      'description' => 'Verifies operation of a taxonomy-based EntityFieldQuery.',
+      'group' => 'Taxonomy',
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+    $this->admin_user = $this->drupalCreateUser(array('administer taxonomy'));
+    $this->drupalLogin($this->admin_user);
+    $this->vocabulary = $this->createVocabulary();
+  }
+
+  /**
+   * Tests that a basic taxonomy EntityFieldQuery works.
+   */
+  function testTaxonomyEFQ() {
+    $terms = array();
+    for ($i = 0; $i < 5; $i++) {
+      $term = $this->createTerm($this->vocabulary);
+      $terms[$term->tid] = $term;
+    }
+    $query = new EntityFieldQuery();
+    $query->entityCondition('entity_type', 'taxonomy_term');
+    $result = $query->execute();
+    $result = $result['taxonomy_term'];
+    ksort($result);
+    $this->assertEqual(array_keys($terms), array_keys($result), 'Taxonomy terms were retrieved by EntityFieldQuery.');
+  }
+}
