Answers.Body: <p>This happens when you have separate database for civicrm tables. Below patch in civicrm_entity module fixes problem for <code>'Base table or view not found:'</code></p>
  
  <pre><code>diff --git a/src/CivicrmEntityViewsData.php b/src/CivicrmEntityViewsData.php
  index 51db201..ffbb31d 100644
  --- a/src/CivicrmEntityViewsData.php
  +++ b/src/CivicrmEntityViewsData.php
  @@ -17,6 +17,8 @@ class CivicrmEntityViewsData extends EntityViewsData {
       $base_table = $this-&gt;entityType-&gt;getBaseTable() ?: $this-&gt;entityType-&gt;id();
       $base_field = $this-&gt;entityType-&gt;getKey('id');
  
  +    $database = _civicrm_get_db_config()['key'];
  +
       // Setup base information of the views data.
       $data[$base_table]['table']['group'] = sprintf('%s (CiviCRM Entity)', $this-&gt;entityType-&gt;getLabel());
       $data[$base_table]['table']['provider'] = $this-&gt;entityType-&gt;getProvider();
  @@ -27,6 +29,7 @@ class CivicrmEntityViewsData extends EntityViewsData {
         'field' =&gt; $base_field,
         'title' =&gt; $this-&gt;entityType-&gt;getLabel(),
         'cache_contexts' =&gt; $this-&gt;entityType-&gt;getListCacheContexts(),
  +      'database' =&gt; $database,
       ];
       $data[$base_table]['table']['entity revision'] = FALSE;
       if ($label_key = $this-&gt;entityType-&gt;getKey('label')) {
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-28T13:25:47.257Z
Answers.Text: We've been using the same "CMS Database Integration" code that would go into the Drupal settings.php as was in D7 but perhaps this is better. Will check it out.
Answers.UserDisplayName: jackrabbithanna
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-28T02:59:49.400Z
Answers.LastActivityDate: 2020-01-28T11:22:48.417Z
Answers.LastEditDate: 2020-01-28T11:22:48.417Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>On latest version of 8.x-3.x branch i get following error when try to add a view for contribution page</p>
  
  <p>SQLSTATE[42S02]: Base table or view not found: 1146 Table 'civicrmdb.civicrm_contribution_page' doesn't exist: SELECT civicrm_contribution_page.id AS id FROM {civicrm_contribution_page} civicrm_contribution_page LIMIT 11 OFFSET 0; Array ( )</p>
  
  <p>views for Contact, Contribution, Event works fine but not incase of Contribution page, Payment processor, campaign etc.</p>
  
  <p>Can we create list of contribution pages/campaigns/payment processors using  civicrm_entity + civicrm views d8?</p>
  
Tags: <drupal-views><civicrm-entity><drupal-8>
Title: Base table not found for civicrm_contribution_page #201
ThreadText: # Base table not found for civicrm_contribution_page #201
  
  (Asked by: username_0 on 2020-01-28)
  
  On latest version of 8.x-3.x branch i get following error when try to add a view for contribution page
  
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'civicrmdb.civicrm\_contribution\_page' doesn't exist: SELECT civicrm\_contribution\_page.id AS id FROM {civicrm\_contribution\_page} civicrm\_contribution\_page LIMIT 11 OFFSET 0; Array ( )
  
  views for Contact, Contribution, Event works fine but not incase of Contribution page, Payment processor, campaign etc.
  
  Can we create list of contribution pages/campaigns/payment processors using civicrm\_entity + civicrm views d8?
  
  **Tags:** drupal-views, civicrm-entity, drupal-8
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-01-28. Score: 1 | Accepted answer
  
  This happens when you have separate database for civicrm tables. Below patch in civicrm\_entity module fixes problem for `'Base table or view not found:'`
  
  ```
  diff --git a/src/CivicrmEntityViewsData.php b/src/CivicrmEntityViewsData.php
  index 51db201..ffbb31d 100644
  --- a/src/CivicrmEntityViewsData.php
  +++ b/src/CivicrmEntityViewsData.php
  @@ -17,6 +17,8 @@ class CivicrmEntityViewsData extends EntityViewsData {
       $base_table = $this->entityType->getBaseTable() ?: $this->entityType->id();
       $base_field = $this->entityType->getKey('id');
  
  +    $database = _civicrm_get_db_config()['key'];
  +
       // Setup base information of the views data.
       $data[$base_table]['table']['group'] = sprintf('%s (CiviCRM Entity)', $this->entityType->getLabel());
       $data[$base_table]['table']['provider'] = $this->entityType->getProvider();
  @@ -27,6 +29,7 @@ class CivicrmEntityViewsData extends EntityViewsData {
         'field' => $base_field,
         'title' => $this->entityType->getLabel(),
         'cache_contexts' => $this->entityType->getListCacheContexts(),
  +      'database' => $database,
       ];
       $data[$base_table]['table']['entity revision'] = FALSE;
       if ($label_key = $this->entityType->getKey('label')) {
  
  ```
  
  > **Comments:**
  > **username_1**: We've been using the same "CMS Database Integration" code that would go into the Drupal settings.php as was in D7 but perhaps this is better. Will check it out.  
  
  ---
  
  