title: Entity Framework - Where is my Object Context?
body: <p>Ok, I'm obviously missing something very basic.  I'm very new to Entity Framework.</p>
  
  <p>I want to call stored procedures without importing them, so I was planning on using ExecuteStoreQuery().  According to the documentation, ExecuteStoreQuery is a method of ObjectContext.  But, I have no idea where to get my ObjectContext.</p>
  
  <p>I generated my entites using Database First.  So far, I have been accessing my entities something like this:</p>
  
  <pre><code>var db = new MyEntities();
  
  PRODUCT p = db.PRODUCTS.First(a =&gt; a.PRODUCTSKEY == thekey);
  </code></pre>
  
  <p>But I can't call db.ExecuteStoreQuery, becase db isn't an ObjectContext.</p>
  
  <p>I've googled how to get ObjectContext from an entity.  I find some answers, but they're all flagged with cautions, saying that it's a workaround, and only to use it if you have no other option.  Ok, so what is the RIGHT way?</p>
  
  <p>All examples that I've found for using ExecuteStoreQuery assume that you already have your ObjectContext.  Not very helpful.  </p>
  
  <p>I found one website that stated that the ObjectContext is "automatically generated" by Entity Framework.  If that's the case, then where is it?</p>
  
  <p>I'm obviously missing something very simple here.  This can't be that difficult.</p>