title: Error: Only primitive types or enumeration types are supported in this context EF
body: <p>This piece of code keep making this error. :</p>
  
  <blockquote>
    <p>Unable to create a constant value of type 'Repository.DBModel.Subscriber'. Only primitive types or enumeration types are supported in this context. </p>
  </blockquote>
  
  <p>I've Changed it a few times but it keeps coming up with this Error. </p>
  
  <pre><code>using (SubscriberDBHandler db = new SubscriberDBHandler())
  {
      IEnumerable &lt;Subscriber&gt; NewSubscribers = Subscribers
                                                .Where(sub =&gt; db.Subscriber
                                                .Any(aSub =&gt; !aSub.Email.Equals(sub.Email)));
      List&lt;Subscriber&gt; updateSubscribers = db.Subscriber
                                             .Where(dbSub =&gt; Subscribers
                                             .Any(lSub =&gt; lSub.Email
                                             .Equals(dbSub.Email))).ToList();
      if(NewSubscribers.Count() &gt;= 1)
      {
          db.Subscriber.AddRange(NewSubscribers);
      }
      updateSubscribers.ForEach(aSub =&gt; aSub.State = Subscribers
                                                    .FirstOrDefault(sub =&gt; sub.Email
                                                    .Equals(aSub.Email)).State ?? "Error" );
      db.SaveChanges();
  }
  </code></pre>
  
  <p>I'd greatly appreciate if someone could point out my error or come up with a more efficient way to do this. </p>
  
  <p>In advance thanks for your time and help. </p>
  
  <hr>
  
  <p>I know there are a few post with this error out there but when reading them I can't figure out how they relate to my problem. so I'm sorry if this is a common mistake and others have provided a solution</p>
  
  <p>The object Subscribers is a <code>List&lt;Subscriber&gt;</code></p>
  
  <p>I don't seem to be able to find the line but. the stack trace does contain this. </p>
  
  <blockquote>
    <p>at System.Linq.Enumerable.ToList[TSource](IEnumerable<code>1 source)
       at Repository.SubScribRepository.AddOrUpdateSubscribers(List</code>1 Subscribers)</p>
  </blockquote>