Looking in EntityFramework.psm1
it is merely a scripting facade for the EntityFramework.PowerShell.dll. The actual add-migrations functionality is implemented in the System.Data.Entity.Migrations.AddMigrationCommand
class in that assembly.
Looking at the source, it gets the currently active project (I assume that's the project that's selected in the powershell console) through this line:
get { return (Project)_domain.GetData("project"); }
Project
is EnvDTE.Project
which (if I google correctly) is a way to interface with the IDE. Some further source reading reveals that files are added to the project by interfacing with the IDE.
To me it looks like the scaffolding code is too heavily integrated with the Visual Studio to be possible to run outside of Visual Studio as part of a command line build.
Edit
I'm getting back to this and figured out that it might be possible. There's another SO question that describes how to use EnvDTE outside of visual studio, e.g. from command line apps:
Open DTE solution from another program (not add-in)
So it might indeed be possible to write an own .exe wrapper around the EntityFramework.PowerShell.dll
if the app domain is prepared with the proper EnvDTE objects before calling the AddMigrationCommand
class. To do that you would have to analyze the Entity Framework source code to know how to fool the scaffolding code to beleive it runs inside of Visual Studio.
So, in the end: It might be possible - but it will be a non trivial project to write your own tool for it.