title: Cannot get DbSet.Find to work with Moq (Using the Entity-Framework)
body: <p>For some reason this code keeps failing. Anyone that can tell me why:</p>
  
  <pre><code>        var activeLoans = new List&lt;ActiveLoan&gt; {
              new ActiveLoan{
                 ID = 1,
                 CaseType = "STL",
                 LoanCode = 0
              },
              new ActiveLoan{
                 ID = 2,
                 CaseType = "STL",
                 LoanCode = 0
              },
              new ActiveLoan{
                 ID = 3,
                 CaseType = "STL",
                 LoanCode = 0
              }
          }.AsQueryable();
  
          var activeLoanMockSet = new Mock&lt;DbSet&lt;ActiveLoan&gt;&gt;(); 
          activeLoanMockSet.As&lt;IQueryable&lt;ActiveLoan&gt;&gt;().Setup(m =&gt; m.Provider).Returns(activeLoans.Provider);
          activeLoanMockSet.As&lt;IQueryable&lt;ActiveLoan&gt;&gt;().Setup(m =&gt; m.Expression).Returns(activeLoans.Expression);
          activeLoanMockSet.As&lt;IQueryable&lt;ActiveLoan&gt;&gt;().Setup(m =&gt; m.ElementType).Returns(activeLoans.ElementType);
          activeLoanMockSet.As&lt;IQueryable&lt;ActiveLoan&gt;&gt;().Setup(m =&gt; m.GetEnumerator()).Returns(activeLoans.GetEnumerator());
          mockContext.Setup(c =&gt; c.ActiveLoans).Returns(activeLoanMockSet.Object);
  
  
          // This is the line that fails
          Assert.AreNotEqual(mockContext.Object.ActiveLoans.Find( 1 ), null);
  </code></pre>
  
  <p>When I say fail i mean that the unit test that this is a part of fails.</p>