无法在 Visual Studio 2022、EF6 Code First 中运行添加迁移

Tua*_*Anh 2 c# entity-framework visual-studio-2022

我尝试在 Visual Studio 2022、EntityFramework 6 上添加迁移,但它不起作用。我收到一个错误

PM> EntityFramework\Add-Migration -ConfigurationTypeName STS.Core.Migrations.Configuration "AddCheckChanges"
System.ArgumentNullException: Value cannot be null.
Parameter name: type
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)
   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebSiteProject(Project project)
   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetTargetDir(Project project)
   at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
   at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Value cannot be null.
Parameter name: type
Run Code Online (Sandbox Code Playgroud)

我需要这方面的帮助。非常感谢

Moh*_*eri 5

对于使用 Visual Studio 2022 确实遇到此问题的用户:请切换回 Visual Studio 2019,因为当您使用较旧的实体框架版本时,它在 2022 版本中尚不起作用。

关于Entity Framework 6 GitHub 存储库上的相关问题文件,项目成员 ajcvickers于 2021 年 11 月 18 日发表评论

[...] EF 6.2 doesn't work. You will need to update to EF 6.4.4. We have so far been unable to reproduce this with EF 6.4.4.
Run Code Online (Sandbox Code Playgroud)

尽管许多用户报告升级到 EF 6.4.4 解决了他们的问题,但问题仍然存在,因为有些用户无法降级到 Visual Studio 2019 或升级实体框架,因为这些更改可能会破坏管道。