Route factory which creates instances based on database context and model
Any particular reason you have all those using statements in the namespace itself?



This line:


DbContextTypeWrapper&lt;SapphireDbContext&lt;SiteTree&gt;, SiteTree&gt; dbContextTypeWrapper = new DbContextTypeWrapper&lt;SapphireDbContext&lt;SiteTree&gt;, SiteTree&gt;();



throws a gray-flag for me. Perhaps you should consider injecting the DbContextTypeWrapper into the RouteFactory? It seems to have an awful dependence on certain specifics, that can be abstracted away.

Another suggestion, would be to consider generics for it, considering you also depend on SiteTree as well.

The ideal solution would be an interface ISiteTree that you depend on, regardless of the SiteTree implementation. You could provide a default SiteTree implementation, or allow the additional assemblies to provide their own.

Likewise, the use of internal tends to lend way to some particular properties, for example, the behavior between assemblies can be different. This is particularly foul. You should consider either marking the internal methods public, or marking them private.

Depending on what you have access to, you should consider interfaces/generics again to allow for the DbContextTypeWrapper to vary a little between assemblies. By restricting the public implementation to SapphireDbContext, you also restrict it to only those DB types that SapphireDbContext supports. (If it only supports MSSQL, then you'll need an MSSQL server for each-and-every other project you use this in.)



Though I do not generally advocate the use of var, you could shorten some of your lines with it. (Especially the obscenely long ones.)