aspnet/EntityFramework — pull request #1028 by ajcvickers (2014-11-07 19:48:32+00:00)
Title: Make Database not depend on DbContextConfiguration

This is part of Issue #641 which is about cleaning up the use of DbContextConfiguration. DbContextConfiguration is intended to help resolve dynamic services--that is, services for which the actual type/instance of service to use depends on the current context configuration. However, it has gradually spread throughout the code as a general purpose service locator. This causes dependencies to be hidden and creates a lot of coupling to DbContextConfiguration throughout the code, so I am making a set of changes to help fix this.

This change introduces the idea of registering delegates for dynamic services using the mechanism added recently to the DI abstraction. This allows dynamic services to be depended on in constructors in the normal way. However, since these dynamic services can result in work being done to initialize and build the service the delegates are generally registered to create LazyRef and so this should be depended on. This allows, for example Database to depend on the current model by depending on LazyRef but the model will only be built if the database actually makes use of it.