Search code examples
entity-frameworkentity-framework-corednx

Entity Framework 7 "dnx ef migrations add" missing output file


The EF7 command

dnx ef migrations add XXX 

suddenly stopped working. It gives the normal output to the console...

C:\Users\Nikola\Dev\ScanburSandbox\src\ScanburSandbox>dnx ef migrations add XXX
Done. To undo this action, use 'ef migrations remove'

...but the usual .cs and .designer.cs files are not produced.

Question: Can anyone suggest why this can happen or how I can troubleshoot it?

Some more details:

The content of the Migrations-folder before and after running the command looks like this:

11-02-2016  00:03             7.629 00000000000000_CreateIdentitySchema.cs
11-02-2016  00:03             6.637 00000000000000_CreateIdentitySchema.Designer.cs
11-02-2016  00:08             9.688 20160210230810_modelv2.cs
11-02-2016  00:08            10.103 20160210230810_modelv2.Designer.cs
12-02-2016  15:38             8.636 20160212083018_modelv3.cs
12-02-2016  15:38            10.065 20160212083018_modelv3.Designer.cs
12-02-2016  15:38            10.058 ApplicationDbContextModelSnapshot.cs

I have been running the EF7-tools ("dnx ef migrations" and "dnx ef database") with success many times up to now, each time with the expected outcome. This means that "dnx ef migrations add XXX" will add a new .cs and .designer.cs file every time it is executed. This will happen no matter if the model classes have changes or not.

I have no idea how to troubleshoot this tool. I don't see any debug flag or any log-files written anywhere. I don't see any errors in the output.

I really hope someone has bright ideas as I'm stuck here.


Solution

  • After some more research I finally realized why the migration files were missing.

    I ran again with the verbose flag: dnx ef migrations add v3 -v

    This is the output:

    Finding DbContext classes...
    Using context 'ApplicationDbContext'.
    An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy.
    Reusing directory of file '00000000000000_CreateIdentitySchema.cs'.
    Reusing directory of file 'ApplicationDbContextModelSnapshot.cs'.
    Writing migration to
    'c:\Users\Nikola\Dev\SdmWeb\src\SdmWeb\bin\output\approot\src\SdmWeb\Migrations\20160223195618_v1.cs'.
    Writing model snapshot to
    'c:\Users\Nikola\Dev\SdmWeb\src\SdmWeb\bin\output\approot\src\SdmWeb\Migrations\ApplicationDbContextModelSnapshot.cs'.
    Done. To undo this action, use 'ef migrations remove'
    

    The tricky point here is, that it is 'reusing directory of...' and then later on it says that it is writing the migrations files to ...\bin\output\approot\src.

    After cleaning the bin-folder and running again, the migration files are produced in the Migration folder directly under ...\Migrations as expected.