diff --git a/relation.admin.inc b/relation.admin.inc
index 6ccf8cc..9c75e37 100644
--- a/relation.admin.inc
+++ b/relation.admin.inc
@@ -247,6 +247,7 @@ function relation_generate_form($form, &$form_state) {
     '#title' => t('Relation types'),
     '#description' => t('Select relation types to create relations from. If no types are selected, relations will be generated for all types.'),
     '#options' => $types,
+    '#required' => TRUE,
   );
   $form['relation_number'] = array(
     '#type' => 'textfield',
@@ -273,6 +274,11 @@ function relation_generate_form_submit($form, &$form_state) {
   if (is_numeric($number) && $number>0) {
     $types = array_keys(array_filter($types));
     $rids = relation_generate_relations($number, $types, $kill);
-    drupal_set_message(t("Generated %count relations (rids from %first to %last).", array('%count' => count($rids),'%first' => $rids[0],'%last' => end($rids))));
+    if ($rids) {
+      drupal_set_message(t("Generated %count relations (rids from %first to %last).", array('%count' => count($rids),'%first' => $rids[0],'%last' => end($rids))));
+    }
+    else {
+      drupal_set_message(t("No relations generated. Have you entities available?"));
+    }
   }
 }
diff --git a/relation.module b/relation.module
index f558053..5dad608 100644
--- a/relation.module
+++ b/relation.module
@@ -717,36 +717,38 @@ function relation_generate_relations($number = 10, $types = array(), $kill = FAL
       list($entity_type, $bundle) = explode(':', $bundle_key, 2);
       $available_types['target'][$entity_type][] = $bundle;
     }
-    $arity = rand($relation_type->min_arity, $relation_type->min_arity);
-    for ($i = $number; $i > 0; $i--) { // start new relation
-      $entity_keys = array();
-      for ($r_index = 0; $r_index < $arity; $r_index++) {
-        if ($relation_type->directional && $r_index > 0) {
-          $direction = 'target';
+    if ($available_types) {
+      $arity = rand($relation_type->min_arity, $relation_type->min_arity);
+      for ($i = $number; $i > 0; $i--) { // start new relation
+        $entity_keys = array();
+        for ($r_index = 0; $r_index < $arity; $r_index++) {
+          if ($relation_type->directional && $r_index > 0) {
+            $direction = 'target';
+          }
+          else { //use source bundles
+            $direction = 'source';
+          }
+          $entity_type = array_rand($available_types[$direction]);
+          $query = new EntityFieldQuery();
+          $query->entityCondition('entity_type', $entity_type, '=')
+            // Would be nice to ->entityOrderBy('RAND()'); here, and set
+            // range(0, 1). See http://drupal.org/node/1174806
+            ->range(0, 2*$number);
+          if (!in_array('*', $available_types[$direction][$entity_type])) {
+            $query->entityCondition('bundle', $available_types[$direction][$entity_type], 'IN');
+          }
+          $results = $query->execute();
+          $entity_ids = array_keys(reset($results));
+          $key = array_rand($entity_ids); //pseudorandomise until EFQ does random.
+          $entity_keys[] = array(
+            'entity_type' => $entity_type,
+            'entity_id'   => $entity_ids[$key],
+            'r_index'     => $r_index,
+            );
         }
-        else { //use source bundles
-          $direction = 'source';
-        }
-        $entity_type = array_rand($available_types[$direction]);
-        $query = new EntityFieldQuery();
-        $query->entityCondition('entity_type', $entity_type, '=')
-          // Would be nice to ->entityOrderBy('RAND()'); here, and set
-          // range(0, 1). See http://drupal.org/node/1174806
-          ->range(0, 2*$number);
-        if (!in_array('*', $available_types[$direction][$entity_type])) {
-          $query->entityCondition('bundle', $available_types[$direction][$entity_type], 'IN');
-        }
-        $results = $query->execute();
-        $entity_ids = array_keys(reset($results));
-        $key = array_rand($entity_ids); //pseudorandomise until EFQ does random.
-        $entity_keys[] = array(
-          'entity_type' => $entity_type,
-          'entity_id'   => $entity_ids[$key],
-          'r_index'     => $r_index,
-          );
+        $relation = relation_create($type, $entity_keys);
+        $new_rids[] = relation_save($relation);
       }
-      $relation = relation_create($type, $entity_keys);
-      $new_rids[] = relation_save($relation);
     }
   }
   return $new_rids;
