Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Bug Microsoft.CodeAnalysis.* version dependencies
ASP.NET Core Web API with EF Core 8.0
I need to reference Microsoft.CodeAnalysis.* directly with a newer version (instead of v4.5.0) because of other dependencies like Powershell.SDK - see #32070
This was working fine until v4.9.2 of Microsoft.CodeAnalysis.* packages. Except the warning about version mismatch.
After update to v4.10.0 the Add-Migration crashes.
Please make it working also with newer versions of Microsoft.CodeAnalysis. and don't stick to an (very) old version.
Directory.Packages.props:
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6" />Stack traces
PM> Add-Migration -Context MyContext -OutputDir Models\DbMigrations -Name "Add my field"
Build started...
Build succeeded.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.get_DefaultHost()
at Microsoft.CodeAnalysis.AdhocWorkspace..ctor()
at Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper..ctor(ITypeMappingSource typeMappingSource)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
System.TypeLoadException: Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
Unable to load one or more of the requested types.
Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
Provider and version information
EF Core version: 8.0.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system: Windows 11 23H2 (Build 22631.3737)
IDE: Visual Studio 2022 17.10 and Visual Studio 2022 17.11 Preview 2.0
Reacted by mikihiro-t, Luboš Běhounek, Andrew Thornton, Frederik Nielsen, Lee Conlin and Arash Zandi
Activity
flipZomb commentedon Jun 14, 2024
Have a similar issue. Going back to "4.9.2" fixed it for now.
ajcvickers commentedon Jun 15, 2024
Duplicate of #32926
pocki commentedon Jun 15, 2024
Its not a duplicate, as it is a current problem and not in next major release in half a year
roji commentedon Jun 16, 2024
@pocki the problem has already been fixed for 9.0 - the remaining question is about whether to also backport a fix for 8.0. That discussion is happening as part of #32926.
pocki commentedon Jun 16, 2024
@Roj At the mentioned PR there is only an update to v4.8 - this is still not the latest version. And there are breaking changes from 4.9.2 to 4.10
peter-nguyen-contemi commentedon Jul 22, 2024
@roji Could you please consider the comment from @pocki . It seems that he mentioned a wrong person in his comment. Right now we cannot add any new EF Core migrations with Microsoft.CodeAnalysis.* packages version 4.10.0 because of this issue.
We had to downgrade them to version 4.9.2 for the EF Core tool to work properly.
roji commentedon Jul 22, 2024
Ropening to make sure we do the right thing for 9.0 here.
30 remaining items
eqtr-ab commentedon Mar 11, 2025
The status quo also breaks a lot of people, such as myself and previous commenters. Umbraco, a popular CMS package, has a dependency on v4.10.0 of CodeAnalysis specifically - this appears to present a situation where any Umbraco solution which also makes use of this version of EF Core cannot add any migrations. I'm sure there'll be other packages out there which are also dependent on this version.
roji commentedon Mar 11, 2025
It's very different to say that there's an incompatibility using EF with some other, unrelated package (Umbraco), and asking for a breaking change to be done in an EF 9.0; the latter would cause EF users upgrading to a new patch version (regardless of any other packages). There is an extremely high bar for us for introducing a breaking change in a patch version, and this doesn't seem anywhere close to it.
If you prefer, you can stay with EF 8.0 for now, until 10 is released in a few months. Otherwise, you can also file a request with Umbraco to support earlier versions of Microsoft.CodeAnalysis.
eqtr-ab commentedon Mar 11, 2025
EF8 is the version I am using, and the version both myself and OP encountered this issue in. I am not asking for any changes to be made to 9, 8 is the version exhibiting this issue. Can I assume your answer is the same in this circumstance, and this issue will not be resolved for this version either?
roji commentedon Mar 11, 2025
@eqtr-ab yes, that same logic holds - even more so - for EF 8.0, which is a long-term release. We'd be breaking existing EF 8.0 users by releasing an 8.0 patch version that changes the Microsoft.CodeAnalysis version.
LennardF1989 commentedon Apr 7, 2025
If it's worth anything to anyone, I fixed my .NET 8 projects with the following:
Specifically, adding the first two packages was key - in my case, transitive dependencies were mixing 4.5.0 and 4.10.0, which caused the
dotnet ef migrations addto fail.AndrewZenith commentedon Apr 8, 2025
Just upgraded to
PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.13.0"
No more migration building issues.
DennisBergemann commentedon Jun 11, 2025
Hi, we have dotnet core 9 project with WPF and Entity Frame work. Sincerely we on the same issue above.
one of the messages
Method 'get_IsExtension' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationArrayTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.i updated for my project to 4.14.0 as a test with no luck.
Any suggestions ?
DennisBergemann commentedon Jun 11, 2025
Sorry the fix is like from @LennardF1989
updates this packages to the newest
rogmauri commentedon Jul 7, 2025
Issue not yet resolved in version:
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />DennisBergemann commentedon Jul 7, 2025
@rogmauri hi 😬 please have a look to all related packages. Open package manager and search for mentioned packages above and related. I know it’s really anoying , but the project installs this packages with older versions where some functions not implemented.
Believe me you can solve this.
rogmauri commentedon Oct 6, 2025
The only possible workaround, so far, was to revert 'Microsoft.CodeAnalysis.Common' to version 4.9.2
hanoitown commentedon Oct 9, 2025
I upgrade dotnet 8->9 and I solved this issue by upgrade Microsoft.VisualStudio.Web.CodeGeneration.Design to v9
rogmauri commentedon Oct 9, 2025
We already use .NET 9.
Avionworx commentedon Dec 8, 2025
Tried version 5.0.0 with .NET10 EF project. No luck. Same issue as above
why Microsoft.EntityFrameworkCore.Design 10.0.0 still references 4.14.0 and not 5.0.0?
hades200082 commentedon Dec 8, 2025
@Avionworx Since this is closed, probably worth opening a new one and referencing this one.
I've not been using .NET so much let alone EFCore. More NextJS/Drizzle based these days.