title: .NET Core API: Invalid column name '__roleName_0' on upgrading to EF Core 3.1 on docker container running on Linux VM
body: <p><strong>Some context of the issue:</strong></p>
  
  <p>We have recently upgraded to .NET Core 3.1 from 2.2 and with it also upgraded to EF Core 3.1 from 2.2 and there are few APIs which are failing or have some weird issues which were not there until now. I want help to understand such issues in order to fix them.</p>
  
  <p><strong>Some points of observations to note:</strong></p>
  
  <ol>
  <li>The issue does not occur if I downgrade EF Core 3.1 to 2.2</li>
  <li>The issue does not appear when we test API locally, it only appears when we deploy the API.</li>
  <li>For deployment, we use a docker container on a linux VM. I have shared docker file below with other details.</li>
  </ol>
  
  <p><strong>Description</strong></p>
  
  <p>Error type: SqlException
  Error message: Invalid column name '__roleName_0'</p>
  
  <pre><code>public async Task&lt;List&lt;UserView&gt;&gt; GetUsersAsync(string roleName, int offset, int? limit)
  {
      var query = _dbContext.UserView.AsNoTracking().Where(u =&gt; u.UserRole.Any(ur =&gt; ur.Role.Name == roleName));
  
      var userResult = await query.ToListAsync();
  
      return userResult;
  }
  </code></pre>
  
  <p>So as you can see in <code>GetUsersAsync</code> function, It has one db operations:</p>
  
  <ol>
  <li>Get users filtered by predicate belonging to that role.</li>
  </ol>
  
  <p>Here is the generated sql from our logs for the following operations:</p>
  
  <p>Get users filtered by predicate belonging to that role.</p>
  
  <pre><code>Executed DbCommand (177ms) [Parameters=[@__roleName_0='?' (Size = 4000)]
  </code></pre>
  
  <pre><code>SELECT &lt;ColumnNames&gt;
  FROM 
  (
      SELECT &lt;ColumnNames&gt;
      FROM [V_User] AS [v]
      WHERE (EXISTS (
          SELECT 1
          FROM [UserRole] AS [u]
          INNER JOIN [Role] AS [r] ON [u].[RoleId] = [r].[Id]
          WHERE [v].[Id] = [u].[UserProfileId]) AND ([r].[Name] = @__roleName_0)
  )
  </code></pre>
  
  <p><strong>For some reason EF Core is perceiving the parameter __roleName_0 as column which seems to be the problem.</strong> We have tried several resources including reading the breaking changes introduced in EF Core 3.0/3.1 but could not get what is the reason for this issue. Please help.</p>
  
  <p>Other technical details:</p>
  
  <pre><code>&lt;PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" /&gt;
  &lt;PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" /&gt;
  &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2"&gt;
  &lt;PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.2" /&gt;
  &lt;PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" /&gt;
  </code></pre>
  
  <p><strong>Dockerfile:</strong></p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.2 AS base
  WORKDIR /app
  EXPOSE 80
  
  FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
  WORKDIR /src
  COPY &lt;ProjectName&gt;/&lt;ProjectName&gt;.csproj &lt;ProjectName&gt;/
  RUN dotnet restore &lt;ProjectName&gt;/&lt;ProjectName&gt;.csproj
  COPY . .
  WORKDIR /src/&lt;ProjectName&gt;
  RUN dotnet build &lt;ProjectName&gt;.csproj -c Release -r ubuntu.16.04-x64 -f netcoreapp3.1 -o /app
  
  FROM build AS publish
  RUN dotnet publish &lt;ProjectName&gt;.csproj -c Release -r ubuntu.16.04-x64 -f netcoreapp3.1 --self-contained -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "&lt;ProjectName&gt;.dll"]
  </code></pre>