title: Mock a PART of EF DbContext with Moq and/or InMemoryDbSet
body: <p>This question is <strong>NOT</strong> about what's here: <a href="https://stackoverflow.com/questions/25960192/mocking-ef-dbcontext-with-moq">Mocking EF DbContext with Moq</a> and/or similar questions. I am well aware of that. Please, read the question before replying. Thanks.</p>
  
  <ol>
  <li><p>We have a fairly complicated database, which has some, call them, "business objects" and some, call them, "data objects". The "business objects" are usually created or updated with every new user request and the "data objects" are fairly stable but may be occasionally created during user request if missing at the first call.</p></li>
  <li><p>I want to create integration tests in the <strong>sand box</strong> where I could pull the <em>data objects</em> out of the real database (because there are too many of them to mock) but control what happens with the <em>business objects</em>. For example, if I have a <code>get or create</code> workflow (with some validation, of course), then I want explicitly test that <strong>whole workflow</strong> after testing separately <code>get</code> or <code>create</code> workflows in some other tests. However, if I test <code>get or create</code> workflow, then with the real DB I can only test <code>create</code> part of workflow once but then I will only hit a <code>get</code> workflow (because the object will exist after the first test run). Throw in that many tests are routinely run in parallel and the results become unpredictable.</p></li>
  </ol>
  
  <p>I wonder what is the proper approach to perform a <strong>partial</strong> "mock" of a database context where most of the tables would come from the real DB but a few tables could be setup per test, e.g. in <code>InMemoryDbSet</code>s</p>
  
  <p>Thanks a lot!</p>