Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Migration "No connection string named 'DefaultConnection' could be found..."

I have been working with MVC5 and Entity Framework 6 for the past few months. I have separated my main models/business logic and "Migrations" to a separate assembly and referenced it in my web application. Migrations have been working just fine.

Today I ran "Update-database" and I get "No connection string named 'DefaultConnection' could be found in the application config file."

The 'DefaultConnection' is STILL in my web.config file. If I copy the section to the project where the Migrations are located, it works again. If I remove the section, it throws that error. I don't know what might have changed.

The only thing I did since yesterday was run "Disk Cleanup" to clear up space on my HD.

like image 974
FrankO Avatar asked Apr 01 '14 21:04

FrankO


2 Answers

Okay. After some obscure Google searches I found the answer. Apparently my project containing the Migration code was set as the "Startup Project".

After resetting my web application as the Startup Project (and making sure the 'Default Project' in the Package Manager is set to my Migrations project), it started working again!

Problem solved!

like image 176
FrankO Avatar answered Sep 19 '22 12:09

FrankO


Make sure that the execution of a command from Nuget console you choose the right project enter image description here

like image 31
Ilya Avatar answered Sep 19 '22 12:09

Ilya