首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于VSTS的.NET核心EF迁移

基于VSTS的.NET核心EF迁移
EN

Stack Overflow用户
提问于 2018-06-04 00:46:38
回答 1查看 270关注 0票数 2

当我试图在我的机器上本地构建一个迁移脚本时,它工作得很好。然而,在VSTS构建中,我得到了一个奇怪的例外:

代码语言:javascript
复制
**Exception message:**
The migration 'ΓÇôp' was not found.

**Verbose Log:**
dotnet exec --depsfile D:\a\1\s\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.deps.json --additionalprobingpath C:\Users\VssAdministrator\.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback" --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig D:\a\1\s\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.runtimeconfig.json "C:\Program Files\dotnet\sdk\2.1.300-rc1-008673\DotnetTools\dotnet-ef\2.1.0-rc1-final\tools\netcoreapp2.0\any\tools\netcoreapp2.0\any\ef.dll" migrations script -p ..\Company.BaseClassLibrary\Company.BaseClassLibrary.csproj -o D:\a\1\a\Migrations\migration.sql -i --assembly D:\a\1\s\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.dll --startup-assembly D:\a\1\s\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.dll --project-dir D:\a\1\s\Company.API.Auth\ --language C# --working-dir D:\a\1\s\Company.API.Auth --verbose --root-namespace Company.A...
Using assembly 'Company.API.Auth'.
Using startup assembly 'Company.API.Auth'.
Using application base 'D:\a\1\s\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0'.
Using working directory 'D:\a\1\s\Company.API.Auth'.
Using root namespace 'Company.API.Auth'.
Using project directory 'D:\a\1\s\Company.API.Auth\'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding BuildWebHost method...
Using environment 'Development'.
Using application service provider from BuildWebHost method on 'Program'.
Found DbContext 'ApplicationContext'.
Finding DbContext classes in the project...
Using context 'ApplicationContext'.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding IDesignTimeServices implementations in assembly 'Company.API.Auth'...
No design-time services were found.
System.InvalidOperationException: The migration 'ΓÇôp' was not found.
   at Microsoft.EntityFrameworkCore.Migrations.MigrationsAssemblyExtensions.GetMigrationId(IMigrationsAssembly assembly, String nameOrId)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateScript(String fromMigration, String toMigration, Boolean idempotent)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.ScriptMigration(String fromMigration, String toMigration, Boolean idempotent, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScriptMigration.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The migration 'ΓÇôp' was not found.
Process completed with exit code 1.

如果我在我的本地机器上尝试同样的方法,它可以正常工作:

代码语言:javascript
复制
C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth>dotnet ef migrations script -p ..\Company.BaseClassLibrary\Company.BaseClassLibrary.csproj -o %TEMP%\script.sql -i -v
Using project '..\Company.BaseClassLibrary\Company.BaseClassLibrary.csproj'.
Using startup project 'C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\Company.API.Auth.csproj'.
Writing '..\Company.BaseClassLibrary\obj\Company.BaseClassLibrary.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\glen\AppData\Local\Temp\tmpF618.tmp /verbosity:quiet /nologo ..\Company.BaseClassLibrary\Company.BaseClassLibrary.csproj
Writing 'C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\obj\Company.API.Auth.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\glen\AppData\Local\Temp\tmpF7ED.tmp /verbosity:quiet /nologo C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\Company.API.Auth.csproj
dotnet build C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\Company.API.Auth.csproj /verbosity:quiet /nologo

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.86
dotnet exec --depsfile C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.deps.json --additionalprobingpath C:\Users\glen\.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.runtimeconfig.json C:\Users\glen\.nuget\packages\microsoft.entityframeworkcore.tools.dotnet\2.0.0\tools\netcoreapp2.0\ef.dll migrations script -o C:\Users\glen\AppData\Local\Temp\script.sql -i --assembly C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.BaseClassLibrary.dll --startup-assembly C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0\Company.API.Auth.dll --project-dir C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.BaseClassLibrary\ --verbose --root-namespace Company.BaseClassLibrary
Using assembly 'Company.BaseClassLibrary'.
Using startup assembly 'Company.API.Auth'.
Using application base 'C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth\bin\Debug\netcoreapp2.0\netcoreapp2.0'.
Using working directory 'C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.API.Auth'.
Using root namespace 'Company.BaseClassLibrary'.
Using project directory 'C:\Users\glen\source\repos\Company\Company.API.Auth\Company.API.Auth\Company.BaseClassLibrary\'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding BuildWebHost method...
Using environment 'Development'.
Using application service provider from BuildWebHost method on 'Program'.
Found DbContext 'ApplicationContext'.
Finding DbContext classes in the project...
Using context 'ApplicationContext'.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding IDesignTimeServices implementations in assembly 'Company.API.Auth'...
No design-time services were found.
Writing 'C:\Users\glen\AppData\Local\Temp\script.sql'...

VSTS命令行如下所示,并在我的WebAPI项目的工作目录中运行:

代码语言:javascript
复制
dotnet ef migrations script –p ..\Company.BaseClassLibrary\Company.BaseClassLibrary.csproj -o $(Build.ArtifactStagingDirectory)\Migrations\migration.sql -i -v

有什么原因吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-04 04:30:05

通过在VSTS中使用命令行2.x而不是默认的1.x来解决这个问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50672250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档