Skip to content

Commands: Discover contexts registered in the service provider #2293

Closed

Description

@bricelam

(Reported by @glen-84 in #2256)

I'm able to add a DbContext from another assembly using services.AddEntityFramework().AddDbContext<My.ForumDbContext>(), but the context is not listed when you run dnx . ef context list – is it possible to make the migration tools see all DbContexts added in this manner (i.e. via the EntityFrameworkServicesBuilder)?

Activity

  1. added this to the 7.0.0 milestone on May 29, 2015
  2. bricelam commented on May 29, 2015

    @bricelam
    ContributorAuthor

    @ajcvickers commented in #2288:

    Just a thought. When AddDbContext is called it will register the context in D.I. as both its specific type and as just DbContext. So if the AddDbContext mechanism is being used and only a single context type is being used, then the context instance (and its type) could be obtained from the service provider even without first knowing or discovering it. This might be advantageous for cases where the context is in a different assembly. But then again, it might be best just to take a more general approach to that scenario such that we always use the exact type name of the context class.

  3. modified the milestones: , 7.0.0 on Sep 17, 2015
  4. changed the title [-]Commands: ef context list doesn't show contexts registered using AddDbContext[/-] [+]Commands: Discover contexts registered in the service provider[/+] on Sep 25, 2015
  5. modified the milestones: , 1.0.0 on Oct 15, 2022
  6. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions