Skip to content

Decouple design time DbContext instantiaton from migrations commands #2357

Closed as not planned

Description

@divega

Currently EntityFramework.Commands contains what we believed to be the implementation of EF command-line experience for DNX. However, the way we instantiate the application's DbContext (with all its dependencies wired up the same way they would be at runtime) is very ASP.NET specific and not generally applicable to all DNX code.

Issue aspnet/Hosting#286 was about decoupling that mechanism from ASP.NET Hosting but some of us met to analyze that option and came to the conclusion that that isn't the right approach. This issue describes a different way things can be decoupled:

EntityFramework.Commands should depend on an implementation of a contract that can load a context (we should considering keeping the shape and name of IDbContextFactory from EF6 or we can come up with something new). There could be several implementations of this interface, e.g.:

  1. A standard one that mediates between ASP.NET Hosting and EF commands. It should live in its own package, e.g. EntityFramework.Commands.AspNet.
  2. Potentially other standard ones for non-ASP.NET DNX applications
  3. User defined (as with the old IDbContextFactory).

This "loader" would be specified in the registration of the EF commands in the project.json file, e.g.:

"commands": {
    "ef":  "EntityFramework.Commands --loader Microsoft.Data.Entity.Commands.AspNetContextLoader"
},

We can consider falling back to other behaviors in absence of this setting.

Activity

  1. divega commented on Jun 9, 2015

    @divega
    ContributorAuthor
  2. added this to the 7.0.0 milestone on Jun 12, 2015
  3. adamvoss commented on Jun 29, 2015

    @adamvoss

    Traditional .NET (non-DNX) support is relevant for us. No issues with project.json, just wasn't sure if it would be read in a .csproj project.

    http://stackoverflow.com/q/29110241/1072626

  4. rowanmiller commented on Sep 17, 2015

    @rowanmiller
    Contributor

    This is tracked by several other issues too

  5. removed this from the 7.0.0 milestone on Sep 24, 2015
  6. removed their assignment
    on Sep 24, 2015
  7. 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions