gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:04:26 25 4
gpt4 key购买 nike

我尝试在 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

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

最佳答案

对于使用 Visual Studio 2022 确实遇到此问题的用户:请切换回 Visual Studio 2019,因为当您使用较旧的 Entity Framework 版本时,它在 2022 版本中尚无法正常工作。

关于relevant issue file on the Entity Framework 6 GitHub repository ,项目成员ajcvickers commented on 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.

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

关于c# - 无法在 Visual Studio 2022、EF6 Code First 中运行添加迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72855219/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com