As it stands now, the Migrations tooling prevents you from creating your DbContext and DbMigrationsConfiguration classes in different projects.
Steps:
1. Create Project1 with a DbContext in it (start-up project)
2. Create Project2 with a DbMigrationsConfiguration that references Project1 (migrations project)
3. Call Add-Migration
Result:
Could not load assembly 'Project2'. (If you are using Code First Migrations inside Visual Studio this can happen if the startUp project for your solution does not reference the project that contains your migrations. You can either change the startUp project for your solution or use the -StartUpProjectName parameter.)
Problem:
Because Project1 is the startup project, Migrations executes in its output directory. However, Project2.dll doesn't exist in that directory because the assembly reference goes from Project2 to Project1.
Proposed solution:
Ideally, we need a solution that can use Project1's configuration file and assembly resolution, but that can also resolve the Project2 assembly and all of its dependencies.
Steps:
1. Create Project1 with a DbContext in it (start-up project)
2. Create Project2 with a DbMigrationsConfiguration that references Project1 (migrations project)
3. Call Add-Migration
Result:
Could not load assembly 'Project2'. (If you are using Code First Migrations inside Visual Studio this can happen if the startUp project for your solution does not reference the project that contains your migrations. You can either change the startUp project for your solution or use the -StartUpProjectName parameter.)
Problem:
Because Project1 is the startup project, Migrations executes in its output directory. However, Project2.dll doesn't exist in that directory because the assembly reference goes from Project2 to Project1.
Proposed solution:
Ideally, we need a solution that can use Project1's configuration file and assembly resolution, but that can also resolve the Project2 assembly and all of its dependencies.