Ef6: VisualBasic: CompareString cannot be translated

Created on 26 Mar 2019  路  1Comment  路  Source: dotnet/ef6

It looks like Roslyn started embedding this method into user assemblies rather than linking to Microsoft.VisualBasic.dll. This means that some queries may stop working after the project is recompiled using Roslyn. It gives the following error.

System.NotSupportedException : LINQ to Entities does not recognize the method 'Int32 CompareString(System.String, System.String, Boolean)' method, and this method cannot be translated into a store expression.

closed-fixed type-bug

Most helpful comment

If anyone is tripping over this issue with 6.2.0, a workaround, until 6.3.0 is released, is to add the following to your .vbproj file

  <PropertyGroup>
    <VBRuntime>Default</VBRuntime>
  </PropertyGroup>

You may also require to explicitly add the Microsoft.VisualBasic nuget package to ensure the non-embedded version of the function is available.

>All comments

If anyone is tripping over this issue with 6.2.0, a workaround, until 6.3.0 is released, is to add the following to your .vbproj file

  <PropertyGroup>
    <VBRuntime>Default</VBRuntime>
  </PropertyGroup>

You may also require to explicitly add the Microsoft.VisualBasic nuget package to ensure the non-embedded version of the function is available.

Was this page helpful?
0 / 5 - 0 ratings