簡體   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