title: The INSERT statement conflicted with the FOREIGN KEY constraint in Entity Framework
body: <p>I have two table Subscription and PackageType. Subs has FK as PackageTypeId. Now when I am inserting a new record in Subscription table using EF 4.1 it is throwing an exception </p>
  
  <p>The INSERT statement conflicted with the FOREIGN KEY constraint <code>"FK_Subscription_PaymentType"</code>. The conflict occurred in database "MyDatabaseName", table <code>"dbo.PaymentType"</code>, column <code>'Id'</code>.
  The statement has been terminated.</p>
  
  <p>Tables information are:</p>
  
  <p>Subscription Table:</p>
  
  <pre><code>   Id  (PK)
  
     PaymentTypeId (FK)
  
     Period
  
     date 
  </code></pre>
  
  <p>PaymentType:</p>
  
  <pre><code>   Id (PK)
  
     Name
  </code></pre>
  
  <p>And the Code is as given below:</p>
  
  <pre><code>    public void Proceed(SubscriptionSessionData data)
      {
  
          if (data != null)
          {
              PMSCatalogEntities entities = new PMSCatalogEntities();
  
                  Subscription subs = new Subscription();
                  subs.Id = Guid.NewGuid();
                  subs.ApplicableFrom = data.ApplicableFrom;
                  subs.TenantId = tenant.Id;
  
                  subs.PackageId = data.PaymentType;
                  subs.PaymentTypeId = data.PaymentType;
  
                  entities.AddToSubscriptions(subs);
                  entities.SaveChanges();
  
          }
    }
  </code></pre>
  
  <p>Any idea about this issue?</p>