I\'ve recently started using Entity Framework migrations and noticed that the database name is not pulling through for me when I run the Update-Database command
However Update-Database does not read the App.config from the project that contain the migrations (just like the answer 1 year ago) but it will only read *.config from start up project. It is great but I discover how Add-Migration and Update-Database find a suitable connection string here:
MyContext class derived from DbContext so I can use the "MyContext" connection string name. Useful when I have multiple db connections.-ConnectionStringName parameter. See get-help Update-Database to view the help page in the Package Manager Console.There is no retry or fallback attempt, so if the "DefaultConnection" contains a wrong connection string, it will simply show an error.
If both DefaultConnection and context name exist in the connection strings, DefaultConnection will take precedence.
I would prefer #2 become the first try because the name is more specific but the above steps is what EF5 Migrations do when trying to connect to the db.