Why is AutomaticMigrationsDisabledException thrown?

ef-migrations entity-framework entity-framework-6

Question

We have

  • An Old Web Project
  • A New Web Project
  • A Class Library containing all Entity Framework code

All three projects reference Entity Framework 6.1.3.

The Class Library is shared by Old Web Project and New Web Project. Both web projects have a file reference to Class Library. They both point to the same location on disk.

Both web projects are configured to use the same database.

When I run Old Web Project in Visual Studio, it runs just fine.

When I try to run New Web Project in Visual Studio, it throws an AutomaticMigrationsDisabledException.

When I temporarily add ClassLibrary.csproj to the New Web Project's solution and run

Add-Migration TestMigration -ConfigurationTypeName MyConfiguration -ProjectName ClassLibrary -StartupProjectName NewWebProject -ConnectionStringName MyContext

it scaffolds a migration with empty Up() and Down() methods, indicating it did not find changes after all.

What might cause New Web Project to throw an AutomaticMigrationsDisabledException under these circumstances? How can I further diagnose the issue?

1
4
5/20/2015 5:25:17 PM

Accepted Answer

I had very carefully checked that New Web Project's file reference to ClassLibrary.dll is the correct one and that the DLL in question is up-to-date.

As a test, I added a new method to a class in ClassLibrary.dll, and found that New Web Project could not resolve it.

I deleted the existing file reference and added it back in, and the problem resolved.

For an unknown reason, an older copy of ClassLibrary.dll was being referenced in contrast to the information seen in the Properties window for that reference.

1
5/20/2015 5:51:09 PM


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