gpt4 book ai didi

c# - EF 核心迁移失败 : System. Runtime.Remoting.RemotingException : Cannot load type 'Microsoft. EntityFrameworkCore.Design.IOperationResultHandler

转载 作者:行者123 更新时间:2023-11-30 12:56:09 24 4
gpt4 key购买 nike

我第一次将 Entity Framework 核心迁移到我的平均规模项目(大约 100 个表),现在我正在尝试通过包管理器控制台中的“更新数据库”调用对 azure sql db 进行更改。

我总是会收到这个错误:异常信息:堆栈跟踪:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Remoting.RemotingException: Cannot load type 'Microsoft.EntityFrameworkCore.Design.IOperationResultHandler, Microsoft.EntityFrameworkCore.Design, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Server stack trace:
at System.Runtime.Remoting.Messaging.MethodCall.ResolveMethod(Boolean bThrowIfNotResolved)
at System.Runtime.Remoting.Messaging.MethodCall..ctor(SmuggledMethodCallMessage smuggledMsg, ArrayList deserializedArgs)
at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)
at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.EntityFrameworkCore.Design.IOperationResultHandler.OnError(String type, String message, String stackTrace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at Microsoft.EntityFrameworkCore.Tools.AppDomainOperationExecutor.Execute(String operationName, Object resultHandler, IDictionary arguments)
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Microsoft.EntityFrameworkCore.Tools.OperationExecutorBase.InvokeOperationImpl(String operationName, IDictionary arguments)
at Microsoft.EntityFrameworkCore.Tools.OperationExecutorBase.UpdateDatabase(String migration, String contextType)
at Microsoft.EntityFrameworkCore.Tools.Commands.DatabaseUpdateCommand.Execute()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Exception has been thrown by the target of an invocation.

我知道它试图删除这个表的主键 - 在此之前有多个类似的调用:

migrationBuilder.DropPrimaryKey(name: "pk_usr", table: "usr");

我的问题可能是什么原因 - 感谢您的帮助!

引用资料我有(都是1.1.1.0):

Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.Relational
Microsoft.EntityFrameworkCore.Relational.Design
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.SqlServer.Design

最佳答案

检查是否this可以解决您的问题,如果不能继续执行以下选项 EF Tools 1.1.0-preview4 Unrecognized option '--config' #7071

  1. 您是否正在尝试更新已创建的数据库?如果是这样,您的迁移可能与您的迁移数据库不同步快照。您之前没有使用它创建数据库表在不使用的情况下迁移和/或添加或删除列或表迁移,忘记使用当前的迁移并创建一个新的数据库。
    1. 其他一些原因可能是您在 class library , this doesn't currently work ;
    2. 另一个原因可能是您在 .Net Core 运行时使用了一些包由于可能的更新,目前未被引用,因此请确保您正在使用引用的包
    3. 或者可能是,you updated your solution, or your solution usedupdated nuget packages that are not supported by the installed .NETCore Runtime. Ckeck that or the Vice versa .

关于c# - EF 核心迁移失败 : System. Runtime.Remoting.RemotingException : Cannot load type 'Microsoft. EntityFrameworkCore.Design.IOperationResultHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43201333/

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