Sometimes it is worth incurring a lot of maintenance work if the tests are really valuable. If they aren't of much value then the choice becomes much simpler. :)Â With the copious amounts of advice on "best practices" for testing around (my own included ;) ), it is very easy to lose track of the main aim: checking our code works as we expect. If mocking EF fulfils this aim then go for it! If there are easier, more efficient ways that equally fulfil this aim, then do those. :)
In terms of linking mocks together, I don't think this will apply to EF, but normally with NSubstitute we'd do something like this:
  var order = Substitute.For<IOrder>();
  var productLine1 = Substitute.For<IProductLine>();
  var productLine2 = Substitute.For<IProductLine>();
  order.Key = "ABC";
  productLine1.OrderKey = "ABC";
  productLine2.OrderKey = "ABC";
  order.Products().Returns(new [] { productLine1, productLine2 });
Then you could do something like:
  AssertEqual(2, order.Products.Count());
Note that `.Count()` here is calling real code over a real list, it is only the data behind it that we are faking out. With EF I think it is going to be calling some real code when you do something like `orders.GetAll().Count()`, and we need to make sure we have setup the underlying data with the correct values so that the real code will work correctly with it.
(So I'm imagining code a bit like:
  var lstProductLines = new List<ProductLine> { new ProductLine { OrderKey = "ABC", ProductId = "123" }, new ProductLine { OrderKey = "ABC", ProductId = "456" } };
Note there is no mocking for this bit, it is just setting up real objects with the expected data.)
Â