No connection string named 'MyEntities' could be found in the application config file

Try copying the connections string to the .config file in the MVC project.


You are right, this happens because the class library (where the .edmx file) is not your startup / main project.

You'll need to copy the connection string to the main project config file.

Incase your startup / main project does not have a config file (like it was in my Console Application case) just add one (Startup project - Add New Item -> Application Configuration File).

More relevant information can be found here: MetadataException: Unable to load the specified metadata resource


make sure that you make your project (with the DbContext) as startup

on the project right click and select

OR

Add to the project that is set as startup your connection string in the app.config (or web.config)

OR

Call the command like this

Update-Database -Script -ProjectName '<project name>' -StartupProjectName '<project name>' -ConnectionString 'data source=.;initial catalog=<db name>;integrated security=True;MultipleActiveResultSets=True' -ConnectionProviderName 'System.Data.SqlClient'

Then try again