title: Entity Framework is trying to save the Foreign key tables along with the entity save. How to prevent that?
body: <p>When i am saving belwo CounterpartyFrequency entity as below, its trying to add the legalEntity attached to it. How can i prevent that. i just need the counterpartyfrequency table to insert with     CounterpartyFrequencyId  and LegalEntityId . Plz share your thoughts </p>
  
  <pre><code>[DataContract]
      public class CounterpartyFrequency : EntityBase
      {
          [DataMember]
          [Key]
          public int CounterpartyFrequencyId { get; set; }
  
          [DataMember]
          public string LegalEntityId { get; set; }
  
          [DataMember]
          [ForeignKey("LegalEntityId")]
          public LegalEntity LegalEntity { get; set; }
     }
  </code></pre>
  
  <p>The Entity i want to save is above</p>
  
  <pre><code>using (var dbContext = ConfigurationContext.CreateContext(dbConnection))
                      {
                          foreach (var counterpartyFrequency in counterpartyFrequencies)
                          {
  
  
                              if (
                                  dbContext.CounterpartyFrequencies.Any(
                                      (x) =&gt; x.CounterpartyFrequencyId == counterpartyFrequency.CounterpartyFrequencyId))
                              {
                                  dbContext.CounterpartyFrequencies.Attach(counterpartyFrequency);
                              }
                              else
                              {
                                 dbContext.CounterpartyFrequencies.Add(counterpartyFrequency);
                              }
                          }
  
                         var noc =  dbContext.SaveChanges();
                      }
  </code></pre>