diff --git a/relation_select.module b/relation_select.module
index 3bea175..50e7c01 100644
--- a/relation_select.module
+++ b/relation_select.module
@@ -1104,15 +1104,11 @@ function relation_select_entity_get_bundle($entity_type, $entity){
  * @return string Entity type.
  */
 function relation_select_entity_get_type_from_view($view) {
-  switch ($view->query->base_field) {
-    case 'tid':
-      return 'taxonomy_term';
-    case 'nid':
-      return 'node';
-    case 'uid':
-      return 'user';
-    case 'cid':
-      return 'comment';
+  $entity_info = entity_get_info();
+  foreach ($entity_info as $type => $info) {
+    if ($view->base_table == $info['base table']) {
+      return $type;
+    }
   }
 }
 
