繁体   English   中英

无法使用 add-migration 在 Asp.Net Mvc 项目中添加迁移?

[英]Not able to add migration in the Asp .Net Mvc Project using add-migration?

System.Reflection.TargetInvocationException:调用的目标已引发异常。 ---> System.TypeLoadException:无法从程序集“Microsoft.EntityFrameworkCore,Version=5.0.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60”加载类型“Microsoft.EntityFrameworkCore.Internal.SemanticVersionComparer”。 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor..ctor(IOperationReportHandler reportHandler, IDictionary args) --- 内部异常堆栈跟踪结束 --- 在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Z27226C864BAC7454A8504F8EDBZ15D , Boolean wrapExceptions) 在 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] 参数, CultureInfo 文化) 在 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfoculture) 在系统.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfoculture, Object[] activationAttributes) 在 System.Activator.CreateInstance(Type type, Object[] args) 在 Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor ..ctor(字符串程序集,字符串 startupAssembly,字符串 projectDir,字符串数据目录 , String rootNamespace, String language) 在 Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor() 在 Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsAddCommand.Execute() 在 Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0。 b__0() 在 Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) 在 Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) 调用的目标已引发异常。 PM> add-migration inIt Build started... Build 成功。 System.Reflection.TargetInvocationException:调用的目标已引发异常。 ---> System.TypeLoadException:无法从程序集“Microsoft.EntityFrameworkCore,Version=5.0.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60”加载类型“Microsoft.EntityFrameworkCore.Internal.SemanticVersionComparer”。 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor..ctor(IOperationReportHandler reportHandler, IDictionary args) --- 内部异常堆栈跟踪结束 --- 在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Z27226C864BAC7454A8504F8EDBZ15D , Boolean wrapExceptions) 在 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] 参数, CultureInfo 文化) 在 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfoculture) 在系统.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfoculture, Object[] activationAttributes) 在 System.Activator.CreateInstance(Type type, Object[] args) 在 Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor ..ctor(字符串程序集,字符串 startupAssembly,字符串 projectDir,字符串数据目录 , String rootNamespace, String language) 在 Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor() 在 Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsAddCommand.Execute() 在 Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0。 b__0() 在 Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) 在 Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) 调用的目标已引发异常。

尝试将您的 Microsoft.EntityFrameworkCore.Design 和 Microsoft.EntityFrameworkCore.Tools 更新到与您的 .NET 版本匹配的版本。 如果可以的话,我建议始终使用最新的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM