Answers.Body: <p>For the second part, yes - you can import the contributions <code>Contributions &gt; Import Contributions</code> without linking to memberships which will then show under the Contributions tab.</p>
  
  <p>Contributions are linked to memberships with MembershipPayment so when you have the membership id and contribution id you can link them with:</p>
  
  <pre><code>$result = civicrm_api3('MembershipPayment', 'create', array(
    'membership_id' =&gt; X,
    'contribution_id' =&gt; Y,
  ));
  </code></pre>
  
  <p>The challenge here is to get the right membership and contribution id's to pair up.  You could tackle this in various ways including:</p>
  
  <p>1) if you don't mind a bit of coding, write your own import script to create the Contribution, find the relevant Membership then create the MembershipPayment.</p>
  
  <p>2) if you prefer GUI, import your contributions via the UI, export the contributions and memberships (to get the id's), do some spreadsheet manipulation to produce a csv of contribution and membership ids, then use the <a href="https://civicrm.org/extensions/api-csv-import-gui" rel="nofollow noreferrer">API CSV Importer extension</a> to import these as MembershipPayments</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-05T08:53:08.570Z
Answers.LastActivityDate: 2018-06-05T08:53:08.570Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>If you do want to add the Contribution to a Membership then it would be worth looking at Fuzion's <a href="https://civicrm.org/extensions/api-csv-import-gui" rel="nofollow noreferrer">API CSV Import GUI</a> extension</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-05T21:47:32.030Z
Answers.LastActivityDate: 2018-06-05T21:47:32.030Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>We have a whole bunch of contribution records to import into CiviCRM from our legacy database. The membership records already exist in CiviCRM. I can't find a way to link the new contribution records (to be imported) to the existing membership records. Is there a membership record no. that I could extract and use it to link the contribution record (to be imported) to the membership record. </p>
  
  <p>If that is not an option, can I just import the contribution records without linking them to the membership records? The only downside I can see is I wouldn't be able to see the related contributions while I am on the membership screen. But they will all be visible in the Contributions screen. </p>
  
  <p>I'd appreciate the community's thoughts on this. Thanks,</p>
  
  <p>Raja Mukherjee</p>
  
Tags: <civicontribute><civimember>
Title: Is it mandatory to link Membership to Contributions in CiviCRM
ThreadText: # Is it mandatory to link Membership to Contributions in CiviCRM
  
  (Asked by: username_0 on 2018-06-05)
  
  We have a whole bunch of contribution records to import into CiviCRM from our legacy database. The membership records already exist in CiviCRM. I can't find a way to link the new contribution records (to be imported) to the existing membership records. Is there a membership record no. that I could extract and use it to link the contribution record (to be imported) to the membership record.
  
  If that is not an option, can I just import the contribution records without linking them to the membership records? The only downside I can see is I wouldn't be able to see the related contributions while I am on the membership screen. But they will all be visible in the Contributions screen.
  
  I'd appreciate the community's thoughts on this. Thanks,
  
  username_0
  
  **Tags:** civicontribute, civimember
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-06-05. Score: 1
  
  For the second part, yes - you can import the contributions Contributions > Import Contributions without linking to memberships which will then show under the Contributions tab.
  Contributions are linked to memberships with MembershipPayment so when you have the membership id and contribution id you can link them with:
  $result = civicrm_api3('MembershipPayment', 'create', array(
    'membership_id' => X,
    'contribution_id' => Y,
  ));
  
  The challenge here is to get the right membership and contribution id's to pair up.  You could tackle this in various ways including:
  1) if you don't mind a bit of coding, write your own import script to create the Contribution, find the relevant Membership then create the MembershipPayment.
  2) if you prefer GUI, import your contributions via the UI, export the contributions and memberships (to get the id's), do some spreadsheet manipulation to produce a csv of contribution and membership ids, then use the API CSV Importer extension to import these as MembershipPayments
  
  
  ---
  
  ### Answer by username_2 on 2018-06-05. Score: 0
  
  If you do want to add the Contribution to a Membership then it would be worth looking at Fuzion's [API CSV Import GUI](https://civicrm.org/extensions/api-csv-import-gui) extension
  
  
  ---
  
  