I can type Update-Database
, Enable-Migrations
etc, from Package Manager Console and it works fine.
If I need to do the same from a regular powershell session, or in a psake build file, then how do I do it?
I tried importing the module EntityFramework.5.0.0\tools\EntityFramework.psm1
from the packages directory, and I did get the Update-Database
, Enable-Migrations
functions, but I cannot supply their arguments - they need a project, source, and 6 more - and there is no documentation whatsoever. Can I not automate the database deploy on some machine in our CI chain ?
The problem with importing the module into a PowerShell console is that I believe the module expects to run in a context where it has a Visual Studio DTE object available. That environment is the NuGet Package Manager Console. This issue has been brought up before. Check out this blog post and this SO question.
This blog post shows how to write code that does migrations.
Use
migrate.exe
from EntityFramework NuGet package.https://stackoverflow.com/a/14139229/991267