Skip to content

Add-Migration failing with new Microsoft.CodeAnalysis.Workspaces v4.10.0 #33970

Closed as not planned

Description

@pocki

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

Activity

  1. flipZomb commented on Jun 14, 2024

    @flipZomb

    Have a similar issue. Going back to "4.9.2" fixed it for now.

  2. ajcvickers commented on Jun 15, 2024

    @ajcvickers
    Contributor

    Duplicate of #32926

  3. pocki commented on Jun 15, 2024

    @pocki
    Author

    Its not a duplicate, as it is a current problem and not in next major release in half a year

  4. roji commented on Jun 16, 2024

    @roji
    Member

    @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.

  5. pocki commented on Jun 16, 2024

    @pocki
    Author

    @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

  6. peter-nguyen-contemi commented on Jul 22, 2024

    @peter-nguyen-contemi

    @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.

  7. reopened this on Jul 22, 2024
  8. roji commented on Jul 22, 2024

    @roji
    Member

    Ropening to make sure we do the right thing for 9.0 here.

  9. modified the milestone: 9.0.0 on Jul 22, 2024
  10. 30 remaining items

  11. eqtr-ab commented on Mar 11, 2025

    @eqtr-ab

    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.

  12. roji commented on Mar 11, 2025

    @roji
    Member

    The status quo also breaks a lot of people, such as myself and previous commenters.

    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.

  13. eqtr-ab commented on Mar 11, 2025

    @eqtr-ab

    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?

  14. roji commented on Mar 11, 2025

    @roji
    Member

    @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.

  15. LennardF1989 commented on Apr 7, 2025

    @LennardF1989

    If it's worth anything to anyone, I fixed my .NET 8 projects with the following:

        <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.13.0" />
        <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0" />
        <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.13.0" />
        <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
    

    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 add to fail.

  16. AndrewZenith commented on Apr 8, 2025

    @AndrewZenith

    Just upgraded to
    PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.13.0"

    No more migration building issues.

  17. DennisBergemann commented on Jun 11, 2025

    @DennisBergemann

    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 ?

  18. DennisBergemann commented on Jun 11, 2025

    @DennisBergemann

    Sorry the fix is like from @LennardF1989

    updates this packages to the newest

    <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.14.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
    
  19. rogmauri commented on Jul 7, 2025

    @rogmauri

    Issue not yet resolved in version:

    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />

  20. DennisBergemann commented on Jul 7, 2025

    @DennisBergemann

    @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.

  21. rogmauri commented on Oct 6, 2025

    @rogmauri

    The only possible workaround, so far, was to revert 'Microsoft.CodeAnalysis.Common' to version 4.9.2

  22. hanoitown commented on Oct 9, 2025

    @hanoitown

    I upgrade dotnet 8->9 and I solved this issue by upgrade Microsoft.VisualStudio.Web.CodeGeneration.Design to v9

  23. rogmauri commented on Oct 9, 2025

    @rogmauri

    We already use .NET 9.

  24. Avionworx commented on Dec 8, 2025

    @Avionworx

    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?

  25. hades200082 commented on Dec 8, 2025

    @hades200082

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions