如何从psake构建中运行代码优先迁移? [英] How to run Code-First Migrations from a psake build?
问题描述
我可以从Package Manager控制台中键入 Update-Database
, Enable-Migrations
等,并且运行良好。
I can type Update-Database
, Enable-Migrations
etc, from Package Manager Console and it works fine.
如果我需要在常规的Powershell会话中或在psake构建文件中执行相同的操作,该怎么办?
If I need to do the same from a regular powershell session, or in a psake build file, then how do I do it?
我尝试从packages目录中导入模块 EntityFramework.5.0.0\tools\EntityFramework.psm1
,但确实得到了 Update-Database
, Enable-Migrations
函数,但是我无法提供它们的参数-它们需要一个项目,源以及另外6个-并且没有任何文档。我不能自动在CI链中的某些计算机上部署数据库吗?
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 ?
推荐答案
将模块导入PowerShell控制台的问题我认为该模块希望在具有Visual Studio DTE对象可用的上下文中运行。该环境是NuGet软件包管理器控制台。这个问题已经提过。查看此博客帖子和此<一个href = https://stackoverflow.com/questions/11386672/using-nuget-to-update-project-files-outside-of-package-manager-console> SO问题。
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.
这篇关于如何从psake构建中运行代码优先迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!