Can not use Entity Framework Core 3.1 when set ENV LC_ALL and LANG in docker container
See original GitHub issueNow 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:
- Created 3 years ago
- Comments:20 (15 by maintainers)
Note from triage: we will prepare this for a 3.1 patch since it impacts all machines with Thai locale.
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.