Here are a couple of options:

  1. Look at using another context to implement your MaterializationRepositories and have it backed by an in memory database such as Effort, if that's still working nowadays.
  2. Re-implement the 'Include' functionality yourself on the Materialization. The Expression can be broken down to find the type of the navigation property. Using naming conventions you can work out what foreign key property you need to interrogate to get the correct identifier. To find the target repository you could use reflection over the Materialization looking for the public property of type IEnumerable of the type of the navigation property. As long as you knew the name of the primary key of the target entity (by convention, say) you could then use the foreign key value to find it.

If you have a small number of entity types you'd probably be better off having some kind of switch statement and do some of it manually rather than via reflection.

Apologies that this isn't a fully worked through implementation, but I hope it leads in the right direction.

Related Articles