title: Entity Framework CTP5 - How to Call Stored Procedure?
body: <p>This may be a simple answer, but i can't see how to execute a stored procedure with EF CTP5.</p>
  
  <p>In Entity Framework 4.0, we did this:</p>
  
  <p><code>ExecuteFunction("ContainerName.StoredProcName", new ObjectParameter("Id", id))</code>.</p>
  
  <p>Which is a method on the <code>ObjectContext</code>.</p>
  
  <p>But <code>DbContext</code> has no such method.</p>
  
  <p>How do we call a stored proc? Is it not supported in EF CTP5?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found <a href="http://social.msdn.microsoft.com/Forums/eu/adonetefx/thread/bae30a3d-7a66-4aff-af99-6426cf0483b5" rel="noreferrer">this thread</a>, which states you need to do this:</p>
  
  <pre><code>  var people = context.People.SqlQuery("EXECUTE [dbo].[GetAllPeople]");
  </code></pre>
  
  <p>This raises some concerns:</p>
  
  <p>1) You are now calling a stored prodedure on the <em>set</em>, not the <em>context</em>. Stored procedures should be available context-wide, not tied to a particular entity set. Just like how they are under the "Database" in SQL Server, and not under the "Table".</p>
  
  <p>2) What about <strong>complex types</strong>? I previously had a complex type being returned from a stored procedure. But now, it looks as though you have to map directly to an entity? That doesn't make any sense. I have many stored procs that return a type not directly represented by an ObjectSet/DBSet, which i can't see how i can pull over.</p>
  
  <p>Hope someone can clear this up for me, because from what i understand so far, i won't be able to upgrade to CTP5.</p>