title: How do you use Moles to mole DbContext from querying the database in EntityFramework 4.1?
body: <p>I am using Entity Framework 4.1 for database access and would like to Unit Test the following code:</p>
  
  <pre><code>// Get all the entities including children
  using (MyContext context = new MyContext())
  {
      return context.EmployeeProfiles.Include("EmployeeProperties").ToList();
  }
  </code></pre>
  
  <p>I am using Moles to mole out the database dependency however I am stuck. Which point in the Entity Framework I should begin to mole out.</p>
  
  <p>I was following this <a href="http://weblogs.asp.net/mjarguello/archive/2011/04/26/moles-and-linq-to-sql-mocking-linq-to-sql-behavior.aspx" rel="nofollow">example</a> but it is for LINQ-To-SQL.</p>
  
  <p>I was also thinking of debugging/tracing the Entity Framework to figure out which function to intercept out before the call to the database is made.
  However, it seems that there is no source code available for Entity Framework 4.1 to trace with. See <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/bf44d83f-ba9e-4409-b2b4-11dab776975f" rel="nofollow">discussion</a>.</p>
  
  <p>Can anyone guide me to which function(s) I should be moling out in the DbContext so I can get a list of EmployeeProfiles back?</p>