I am trying to migrate a project from .net core 2.2 to 3.0.
I am getting the error:
Error CS0433 The type 'IAsyncEnumerable< T >' exists in both 'System.Interactive.Async, Version=3.2.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' and 'System.Runtime, Version=4.2.1.0
I tried one suggestion here: https://github.com/aspnet/EntityFrameworkCore/issues/15047 which suggests forcefully updating to System.Interactive.Async 4.0.0. (I added this reference to my project).
However I have another error: Reference to type 'IAsyncEnumerable<>' claims it is defined in 'System.Interactive.Async', but it could not be found
I am using IAsyncQueryProvider and it seems that it is causing the issue.
I did not have these issues in 2.2, and I currently could not find any workaround.
I also tried forceably updating to System.Runtime 4.3.1 which did not help.
As one who stumbled upon this on .NET Core 2.2 but wasn't migrating to 3+, I found another solution on the same issue referenced above. Project file referenced was modified since this comment, so here's a direct link.
In my case I added this target to project file:
<Target Name="AddAssemblyAliasToReactiveAsync"
AfterTargets="ResolveAssemblyReferences"
Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
<ItemGroup>
<ReferencePath Condition=" '%(FileName)' == 'System.Interactive.Async' ">
<Aliases>reactive</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
The suggestion from Panatiotis works, I added the reference to Microsoft.EntityFrameworkCore 3.0 and it worked. This reference was not needed in .NET Core 2.2 for my situation.
Although the question has been answered, I've found here: https://github.com/dotnet/efcore/issues/14239 a person that had a similar problem to this one and almost identical to mine.
The netcoreapp3.1 project using EntityFrameworkCore (3.1.1) and IAsyncEnumerable interface. My build ended with this error:
error CS0433: The type 'IAsyncEnumerable' exists in both 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
The problem was caused by using nuget restore command (not dotnet restore) and I had an old version of nuget.exe. Upgrading to the latest nuget.exe fixed the build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With