You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Decide what to do if we need context from services but it's registered under a base-type #732
There are going to be several places where we try and obtain a context from DI (migrations, database error page, and maybe others).
This is fine if the context is registered under it's exact type but gets harder if it's registered under something different (interface, base type, etc.).
In the error page it just fails in these scenarios at the moment, but I think we should do something central and reuse it across the product. We could try the exact type, then walk up the inheritance chain.
Activity
rowanmiller commentedon Oct 1, 2014
@bricelam not sure if you have thought about this one at all?
bricelam commentedon Oct 2, 2014
Seems fine to walk up the chain and cast to the specific type, ignoring it if it's not (i.e. use
as)This feels like it should be part of #639.
The process for getting the instance would go something like this:
IContextFactory(or similar) if implementedThe process to get the services could go something like this:
DbContextInfo-like classIServicesFactory(or similar) if implementedStartup.Configure()for web apps)bricelam commentedon Oct 8, 2015
AddDbContext<TContext>()registers an instance ofIDbContextFactory<TContext>underIDbContextFactoryand theTContext.Commands take advantage of this by...
IEnumerable<IDbContextFactory>TContextgeneric argumentTContextajcvickers commentedon Jul 8, 2016
I don't think we need to do anything more on this at the moment. Our mechanisms for using AddDbContext and discovering contexts seem to work okay.
rowanmiller commentedon Jul 8, 2016
👍