Ben
Ben

Reputation: 407

Code First Migrations: Could not load file or assembly

I'm having difficulty using Package Manager to run update-database. Specifically, I'm getting a System.IO.FileNotFoundException

Approximately, the structure of my solution is as follows:

Foo.Data has all my EF code in. Foo.Presentation is the presentation layer (in this instance, a MVC5 site)

With Foo.Presentation set as the startup project and Foo.Data set as the default project in Package Manager, whenever I try to run update-database I get:

"Could not load file or assembly 'Foo.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."

If I set Foo.Data as the startup project and the default project I can run update-database (so long as I specify the connection string and provider).

This has been driving me nuts all morning - so if anyone has any ideas, you'll help me get this sorted and preserve what remains of my sanity!


A couple of notes:

Upvotes: 0

Views: 1979

Answers (1)

Ben
Ben

Reputation: 407

Just in case anyone stumbles across this same/similar problem - I was being an idiot.

The cause was a discrepancy in a couple of nuget package versions that were used in both Foo.Data and Foo.Presentation. I had inadvertently used a newer version of the package in Foo.Presentation.

Upvotes: 2

Related Questions