[英]Add-Migration hangs on using context - no error
I'm having an issue with my package manager console.我的 package 管理器控制台出现问题。 I run
Add-Migrations name -Verbose
and it hangs after finding the database context.我运行
Add-Migrations name -Verbose
并在找到数据库上下文后挂起。 Note - this is not my initial migration, that worked fine, this is a new migration.注意 - 这不是我最初的迁移,它工作得很好,这是一个新的迁移。 Also, this is a console app, not a web app, so I'm not worried about the error concerning hosting.
此外,这是一个控制台应用程序,而不是 web 应用程序,所以我不担心有关托管的错误。
> PM> Add-Migration owner -Verbose
Using project 'GWMyBot.Database'.
Using startup project 'GWMyBot'.
Build started...
Build succeeded.
C:\Program Files\dotnet\dotnet.exe exec --depsfile C:\Users\parab\Source\Repos\GWMyBot\GWMyBot\bin\Debug\netcoreapp2.2\GWMyBot.deps.json --additionalprobingpath C:\Users\parab\.nuget\packages --additionalprobingpath C:\ProgramData\Xamarin\NuGet --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\Users\parab\Source\Repos\GWMyBot\GWMyBot\bin\Debug\netcoreapp2.2\GWMyBot.runtimeconfig.json C:\Users\parab\.nuget\packages\microsoft.entityframeworkcore.tools\3.1.3\tools\netcoreapp2.0\any\ef.dll migrations add owner --json --verbose --no-color --prefix-output --assembly C:\Users\parab\Source\Repos\GWMyBot\GWMyBot\bin\Debug\netcoreapp2.2\GWMyBot.Database.dll --startup-assembly C:\Users\parab\Source\Repos\GWMyBot\GWMyBot\bin\Debug\netcoreapp2.2\GWMyBot.dll --project-dir C:\Users\parab\Source\Repos\GWMyBot\GWMyBot.Database\ --language C# --working-dir C:\Users\parab\Source\Repos\GWMyBot --root-namespace GWMyBot.Database
Using assembly 'GWMyBot.Database'.
Using startup assembly 'GWMyBot'.
Using application base 'C:\Users\parab\Source\Repos\GWMyBot\GWMyBot\bin\Debug\netcoreapp2.2'.
Using working directory 'C:\Users\parab\Source\Repos\GWMyBot\GWMyBot'.
Using root namespace 'GWMyBot.Database'.
Using project directory 'C:\Users\parab\Source\Repos\GWMyBot\GWMyBot.Database\'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding Microsoft.Extensions.Hosting service provider...
No static method 'CreateHostBuilder(string[])' was found on class 'Program'.
No application service provider was found.
Finding DbContext classes in the project...
Found DbContext 'MyContext'.
Using context 'MyContext'.
I've let this just sit for nearly an hour, nothing happens.我已经让它坐了将近一个小时,没有任何反应。
I had the same issue when trying to add a migration after changing the base class from DbContext
to IdentityDbContext
.在将基本 class 从
DbContext
为IdentityDbContext
后尝试添加迁移时,我遇到了同样的问题。
It was due to a mismatch in the references for Microsoft.AspNetCore.Identity.EntityFrameworkCore
.这是由于
Microsoft.AspNetCore.Identity.EntityFrameworkCore
的引用不匹配。
Project was on.Net Core 5 prev 7 but I mistakenly added a reference in NuGet for 3.1.项目在.Net Core 5 prev 7 上,但我错误地在 NuGet 中为 3.1 添加了参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.