Skip to content

Multiple projects and migrations #43

Closed

Description

@rhires

I seem to be in a bit of circular issue: I have a Web and a Business project. All my db access is in Business, and so when I'm in my Business directory, and run the command dnx ef migrations add FirstMigration, I get error messages complaining that "A type named 'StartupProduction' or 'Startup' could not be found in assembly Business" - but Startup wouldn't be here, it would be in the other directory/project. But if I do go into my Web project directory, I get different errors about there being no DbContext...

So is that right? Do I need a Startup.cs in my Business project? Or is there some kind of service I need to add (and more than a using statement that points to my Business project, since I have that) to the Startup.cs file?

PS Need to transfer this to the EF area, as it isn't really a documentation issue I have...

Activity

  1. smitpatel commented on Oct 12, 2015

    @smitpatel
    Contributor
  2. rhires commented on Oct 12, 2015

    @rhires
    ContributorAuthor

    Yeah, I saw that one, but I wasn't sure if that was exactly the case, even if it's similar.

    My first instinct is to just create a symlink to Startup.cs from the data access project to the project main, but that's just a hack. Instead, I began looking at the EF code, but then I wondered why it got ugly when @bricelam looked at, but then I realized I didn't understand nearly enough to even properly evaluate "ugly" so I stopped.

    So thinking out loud here, if dnu/dnx knows that there is another project because it's listed in the dependencies, couldn't EF ask dnu/dnx about that? Or does dnu/dnx just keep that information to itself? Anyway, I love this stuff!

  3. bricelam commented on Oct 13, 2015

    @bricelam
    Contributor

    The Startup could not be found error should be resolved (in the nightly builds) by dotnet/efcore#3327.

    We need dotnet/efcore#2679 to fully enable the scenario, and when it's in the commands would look something like this.

    cd src\Business
    dnx ef migrations add MyMigration --startupProject MyWebApplication
  4. added this to the 7.0.0 milestone on Nov 6, 2015
  5. smitpatel commented on Dec 8, 2015

    @smitpatel
    Contributor

    We should have some documentation about how to get EF to work when start-up and context are in different projects.
    Points to include:

    • How to set up startup
    • How to run ef commands
  6. removed this from the milestone on Jan 24, 2017
  7. rowanmiller commented on Feb 1, 2017

    @rowanmiller
    Contributor

    Consolidating with #204

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions