title: Why Entity Framework still has wrong count and wrong "vision of data"
body: <p>I am using EF with Oracle..</p>
  
  <p>I have a test that will run this bit of code</p>
  
  <pre><code>using (var ctx = new Entities())
  {
   ctx.SOMEOBJECTSESSIONs.Add(
      new SOMEOBJECTSESSION()
      {
      SOMEOBJECTSESSIONID = 0,
      SOMEOBJECTSESSIONIDHASH = hash,
      DEVICEDESC = "some device",
      OPERATINGSYSTEMDESC = "Microsoft Windows NT 6.1.7601 Service Pack 1",
      BROWSERDESC = "Chrome27",
      IPADDRESS = "123.132.123.132",
      SOMEOBJECTSESSIONSTATUSID = 9999999999, 
      CREATEDBYSOMEOBJECTID = 9999999999,
      CREATEDDATE = DateTime.Now,
      UPDATEDBYSOMEOBJECTID = 9999999999,
      UPDATEDDATE = DateTime.Now
      }
  );
  
  ctx.SaveChanges()
  }
  </code></pre>
  
  <p>Using this I add a record to the database.. I then went into the database and manually deleted that record.. </p>
  
  <p>When I try and run this test again, the call to SaveChanges dies, just sits there.. Now If I do a </p>
  
  <pre><code> var tmp = ctx.SOMEOBJECTSESSIONs.Count();
  </code></pre>
  
  <p>I get back a count that is one more than what is in the database.. Which to me suggests EF still has a hook locally to the record I deleted.. </p>
  
  <p>I have read numerous articles about refreshing context(didn't work). I have cleared the "Local"</p>
  
  <pre><code>ctx.SOMEOBJECTSESSIONs.Local.Clear()
  </code></pre>
  
  <p>which also did not work..</p>
  
  <p>I would have thought that the fact I am spawning up a new Entities connection it should be getting the data from the database..</p>
  
  <p>How do I fix this? What am I doing wrong?</p>
  
  <p>Cheers,
  J</p>