.net core 部署Dotnet核心实体框架迁移

.net core 部署Dotnet核心实体框架迁移,.net-core,entity-framework-core,octopus-deploy,.net Core,Entity Framework Core,Octopus Deploy,我正在从事一个全新的.netcoreapi项目。我正在尝试使用octopus部署应用程序 我需要从命令行执行迁移的帮助,但我没有得到很多帮助。如果有人能帮助我,那就真的很有帮助了 以下是我迄今为止所尝试的: 我已经通过下面的链接找到了一个解决方案,但它对我来说并不真正有效 为了正确设置dll路径,我不得不对脚本进行一些修改。 下面是它现在的样子 set EfMigrationsNamespace=%Dummy.WebAPI set EfMigrationsDllName=%Dummy.Web

我正在从事一个全新的.netcoreapi项目。我正在尝试使用octopus部署应用程序

我需要从命令行执行迁移的帮助,但我没有得到很多帮助。如果有人能帮助我,那就真的很有帮助了

以下是我迄今为止所尝试的: 我已经通过下面的链接找到了一个解决方案,但它对我来说并不真正有效

为了正确设置dll路径,我不得不对脚本进行一些修改。 下面是它现在的样子

set EfMigrationsNamespace=%Dummy.WebAPI 
set EfMigrationsDllName=%Dummy.WebAPI.deps.dll 
set EfMigrationsDllDepsJson=%Dummy.WebAPI.deps.json 
set EfMigrationsStartupAssembly=%Dummy.Data.dll 
set DllDir=%cd% 
set PathToNuGetPackages=%USERPROFILE%\.nuget\packages 
set PathToEfDll=%PathToNuGetPackages%\microsoft.entityframeworkcore.tools\1.1.1\tools\netcoreapp1.0\ef.dll
ECHO %PathToEfDll%

dotnet exec --depsfile .\%EfMigrationsDllDepsJson% --additionalprobingpath %PathToNuGetPackages% %PathToEfDll% database update --assembly .\%EfMigrationsDllName% --startup-assembly .\%EfMigrationsStartupAssembly% --project-dir . --content-root %DllDir% --data-dir %DllDir% --verbose --root-namespace %EfMigrationsNamespace%
然而,脚本抛出了绑定错误的索引oput,这让我非常困惑。这是个例外

System.IndexOutOfRangeException:索引超出了数组的边界。 在Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.ParseOption(布尔值isLongOption,CommandLineApplication c ommand、字符串[]参数、Int32和索引、CommandOption和option) 在Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(字符串[]args) 位于Microsoft.EntityFrameworkCore.Tools.Program.Main(字符串[]args) 索引超出了数组的边界


有关于这个错误的线索吗?或者我是否应该采取任何其他方法?

看起来,
dotnet exec
命令没有正确生成,因为它在解析命令时有问题

我使用的是dotnet core 2-preview,必须稍微更改批处理文件。我现在为我工作:

set EfMigrationsNamespace=%1
set EfMigrationsDllName=%1.dll
set EfMigrationsDllDepsJson=%1.deps.json
set DllDir=%cd%
set PathToNuGetPackages=%USERPROFILE%\.nuget\packages
set PathToEfDll=%PathToNuGetPackages%\microsoft.entityframeworkcore.tools\2.0.0-preview2-final\tools\netcoreapp2.0\ef.dll

dotnet exec --depsfile .\%EfMigrationsDllDepsJson% --additionalprobingpath %PathToNuGetPackages% %PathToEfDll% database update --assembly .\%EfMigrationsDllName% --startup-assembly .\%EfMigrationsDllName% --project-dir . --data-dir %DllDir% --verbose --root-namespace %EfMigrationsNamespace%

这对我来说确实有效。我认为我遇到的问题是在部署到服务器时使用此脚本。PathToNuGetPackages和PathToEfDll值在不同的服务器或环境中可能不同。nuget文件夹在我正在使用的werver 2012中肯定不可用,因为任何2.0包都部署在我的配置文件下。