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

dnx entity-framework entity-framework-core

Question

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.

1
3
2/12/2016 4:21:23 PM

Accepted Answer

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.

1
2/23/2016 8:19:12 PM

Popular Answer

I'm having the same problem, I haven't had much luck with specifying the project, context, and output directory. It seems like it's just stalling out and not doing anything. I've also tried running it in an Administrator powershell in-case it's some permission issue, but still nothing.

Edit: I tried adding a new migration on a linux machine and that seemed to create the migration fine. Creating migrations afterwards seems to work perfectly now.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow