Skip to content

Construct IDesignTimeDbContextFactory without first discovering all DbContext types #27322

@ajcvickers

Description

@ajcvickers

Currently, services are discovered before creating any IDesignTimeDbContextFactory instance. This ensures that we get the correct DbContext type when multiple may be registered, possibly from different assemblies. However, this is problematic when the context factory is being used as an escape hatch for something that is failing in service discovery--for example, see #27306 and comments on #9076.

To fix this, we could do an initial search using some heuristics. For example, we could search for IDesignTimeDbContextFactory implementations and if there is only one found for one context type which matches the context type specified on the command line, then use it with no further discovery.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions