question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not use Entity Framework Core 3.1 when set ENV LC_ALL and LANG in docker container

See original GitHub issue

Now i use efcore v 3.1.7 in dotnet core TargetFramework netcoreapp3.1 I try to add this 2 line below into my docker file

    ENV LANG th_TH.UTF-8  
    ENV LANGUAGE th_TH:th 

These 2 line of config make my report can generate correctly language in dotnetcore v 2.1 With lib ReportServer ( Microsoft.VisualStudio.ConnectedService.Wcf v15.0.40203.910)

But when i migrate to dotnetcore 3.1 and set that 2 env it make i can not query entity framework core 3.1.7 with this code

var userLogedIn = await _uow.User.Where(w => w.empNo == dataEmpNo).AsNoTracking().FirstOrDefaultAsync(); It alway show error message like this


    {
        "ex": {
            "ClassName": "Microsoft.Data.SqlClient.SqlException",
            "Message": "Invalid column name '__dataEmpNo_0'.",
            "Data": {
                "HelpLink.ProdName": "Microsoft SQL Server",
                "HelpLink.ProdVer": "14.00.1000",
                "HelpLink.EvtSrc": "MSSQLServer",
                "HelpLink.EvtID": "207",
                "HelpLink.BaseHelpUrl": "http://go.microsoft.com/fwlink",
                "HelpLink.LinkId": "20476",
                "SqlError 1": "Microsoft.Data.SqlClient.SqlError: Invalid column name '__dataEmpNo_0'."
            },
            "InnerException": null,
            "HelpURL": null,
            "StackTraceString": "   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__164_0(Task`1 result)\n   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()\n   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\n--- End of stack trace from previous location where exception was thrown ---\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\n   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\n--- End of stack trace from previous location where exception was thrown ---\n   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()\n   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)\n   at ****.Services.UserService.Token(RequestUserLoginModel usermodel) in /*******/Services/UserService.cs:line 256\n   at ****.Controllers.UsersController.Token(RequestUserLoginModel userParam, String q) in /*******/Controllers/UsersController.cs:line 82",
            "RemoteStackTraceString": null,
            "RemoteStackIndex": 0,
            "ExceptionMethod": null,
            "HResult": -2146232060,
            "Source": "Core Microsoft SqlClient Data Provider",
            "WatsonBuckets": null,
            "Errors": null,
            "ClientConnectionId": "5206c80f-d8f8-4b12-81e7-b9c51539b6af"
        }
    }

And when I try to change var dataEmpNo into other name it will change error message

“Message”: “Invalid column name ‘__dataEmpNo_0’.”

follow my variable name too. Same variable name is i use to query. But when i remove config ENV LC_ALL and LANG entity framework it work fine.

Further technical details

Database provider: Microsoft.EntityFrameworkCore.SqlServer 3.1.7 Target framework: netcoreapp3.1 LangVersion 7.1 Microsoft.NET.Sdk.Web Operating system: docker mcr.microsoft.com/dotnet/core/sdk:3.1-buster IDE: . Visual Studio 2019 16.6.0 Microsoft.VisualStudio.ConnectedService.Wcf 15.0.40203.910

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
ajcvickerscommented, Oct 19, 2020

Note from triage: we will prepare this for a 3.1 patch since it impacts all machines with Thai locale.

4reactions
rojicommented, Oct 17, 2020

This is indeed a bug in EF Core, which has already been fixed for 5.0 - it’s recommended that anyone hitting this try out 5.0.0-rc2, which is go-live ready. #18831 contains a workaround for this for 3.1 (by replacing the RelationalSqlGenerationHelper service).

At the time the decision was made to not patch 3.1 for this, am leaving this issue open to discuss this again in triage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using dotnet-ef with docker and asp.net core 3.1
I'm trying to run my application written in asp.net core 3.1 on docker. I need to create database using migrations. While executing dotnet...
Read more >
How to containerize your ASP.NET Core application and ...
Learn how to containerize an ASP.NET Core Web API using Docker which consumes data via Entity Framework Core from a containerized SQL ...
Read more >
Applying Entity Framework Migrations to a Docker Container
I'm going to run through how to deploy an API and a database into two separate Docker containers then apply Entity Framework migrations....
Read more >
Working with Entity Framework & Docker
In this episode, Julie Lerman comes on the show to share some insight and great tips for working with Entity Framework in Docker....
Read more >
Entity Framework Dev Environment in Docker | by Andy Watt
When Docker is used, we essentially end up with 'dev environment as code'. ... to allow us to use Entity Framework Core in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found