gpt4 book ai didi

c# - 运行代码首先迁移更新数据库时出错

转载 作者:可可西里 更新时间:2023-11-01 09:01:08 25 4
gpt4 key购买 nike

我在迁移到我的数据库时遇到了问题,我似乎无法找到我遇到的错误的答案

 System.MissingMethodException: Method not found: 'System.Data.Entity.Migrations.Builders.TableBuilder`1 System.Data.Entity.Migrations.Builders.TableBuilder`1.Index(System.Linq.Expressions.Expression`1>, Boolean, Boolean, System.Object)'.
at Evento.Migrations.initialcreate.Up()
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.c__DisplayClassc.b__b()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.c__DisplayClass2.b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Method not found: 'System.Data.Entity.Migrations.Builders.TableBuilder`1 System.Data.Entity.Migrations.Builders.TableBuilder`1.Index(System.Linq.Expressions.Expression`1>, Boolean, Boolean, System.Object)'.

最佳答案

我遇到了同样的问题,下面是我的解决方法。我希望这对其他人有帮助。

  1. 我从我的引用中删除了 Entity Framework,并从我的 package.config 文件中删除了这些行。
  2. 关闭 Visual Studio 并删除项目文件夹中的所有 EntityFramework DLL 文件
  3. 打开 Visual Studio,然后进行清理和构建
  4. 重新安装 Entity Framework
  5. 重新清理并构建

在那之后,它开始工作了。

关于c# - 运行代码首先迁移更新数据库时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22640904/

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