title: Mocking Entity Context in EF4
body: <p>I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks to mock the entity context generated by EEF.</p>
  
  <pre><code>var context = MockRepository.GenerateMock&lt;SomeDBEntities&gt;();
  IObjectSet&lt;TxMode&gt; objectSet = new List&lt;TxMode&gt; { mode }.AsObjectSet();
  context.Expect(c =&gt; c.TxModes).Return(objectSet);
  </code></pre>
  
  <p>The problem is that <code>c.TxModes</code> is a property of type <code>ObjectSet&lt;TxMode&gt;</code> whereas I am trying to return an <code>IObjectSet&lt;TxMode&gt;</code> and I get the following compile error:</p>
  
  <pre><code>Error 4 The best overloaded method match for 
  
  'Rhino.Mocks.Interfaces.IMethodOptions&lt;System.Data.Objects.ObjectSet
  &lt;Data.Entities.TxMode&gt;&gt;.Return(System.Data.Objects.ObjectSet
  &lt;Data.Entities.TxMode&gt;)' has some invalid arguments.
  </code></pre>
  
  <p>The AsObjectSet extension method comes from <a href="http://devblog.petrellyn.com/?p=189" rel="nofollow noreferrer">here</a>. </p>
  
  <p>Any idea how I can get this to compile?</p>