我发现自己经常通过Package Mnager Console运行这些命令:
Update-Database -ConfigurationTypeName CartConfiguration -Verbose
Update-Database -ConfigurationTypeName IdentityConfiguration -Verbose
Update-Database -ConfigurationTypeName ShopConfiguration -Verbose
有没有办法通过向解决方案添加脚本文件并通过PowerShell
或Package Manager Console
本身执行该脚本(包含上面的行)来自动执行这些操作?
答案 0 :(得分:0)
我这样做的方法是使用Entity Framework提供的Migrate.exe。
迁移后,将其复制到包含迁移的程序集的位置。
然后只需在项目中添加PostBuild步骤,然后通过脚本运行Migrate.exe工具。
我没有将它与ConfigurationTypeName一起使用,但我想它会是这样的:
Migrate.exe whereYourMigrationsAre.dll CartConfiguration/startupConfigurationFile=”MyApp.exe.config”
关于exe的文档可以在这里找到:http://msdn.microsoft.com/en-gb/data/jj618307.aspx