Entity Framework 4.3 – Adding Migrations from AppConfig in different project

When using the new Entity Framework migration features where your DbContext is not in the start up project for the solution you need to explicitly tell the Update-Database command which project to use to get the connection string information from. This can be done by passing a parameter to Update-Database called “StartupProjectName”, so the full command to run in the Package Manager Console is:

PM> Update-Database -StartupProjectName "MyProject.Shell"

PM> Update-Database -StartupProjectName "MyProject.Shell"

Make sure the default project is set to the project that contains your DbContext class.

One thing to note is that migrations will create your DbContext using the default constructor so a connection string name will need to be specified by calling the base constructor.

public class MyContext : DbContext
    public MyContext() :base("DefaultConnection"){ }