问题描述
我使用 EF 6.2 创建了一个新的 Framework Winforms XAF 21.1.4 Winforms 项目
当我尝试通过包管理器控制台启用迁移时,我得到了
System.TypeLoadException: Could not load type 'System.Data.Entity.Infrastructure.Design.Executor+GetContextType' from assembly 'EntityFramework,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089'.
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly,String name,Boolean throwOnError,Boolean ignoreCase,ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name,Boolean ignoreCase)
at System.Activator.CreateInstance(String assemblyString,String typeName,BindingFlags bindingAttr,Binder binder,Object[] args,CultureInfo culture,Object[] activationAttributes,Evidence securityInfo,StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName,Object[] activationAttributes)
at System.AppDomain.CreateInstance(String assemblyName,Object[] activationAttributes)
at System.Data.Entity.Tools.AppDomainExecutor.Execute(String operation,Object resultHandler,IDictionary args)
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site,T0 arg0,T1 arg1,T2 arg2,T3 arg3)
at System.Data.Entity.Tools.ExecutorBase.InvokeImpl(String operation,IDictionary args)
at System.Data.Entity.Tools.ExecutorBase.GetContextType(String contextTypeName,String contextAssemblyName)
at System.Data.Entity.Tools.Commands.MigrationsEnableCommand.Execute()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at System.Data.Entity.Tools.Program.Main(String[] args)
Could not load type 'System.Data.Entity.Infrastructure.Design.Executor+GetContextType' from assembly 'EntityFramework,PublicKeyToken=b77a5c561934e089'.
解决方法
我通过 Nuget 升级到 EF 6.4,然后能够启用迁移