-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Can not use Entity Framework Core 3.1 when set ENV LC_ALL and LANG in docker container #23032
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This issue is lacking enough information for us to effectively reproduce. Please post a runnable project/solution or complete code listing that demonstrates the behavior you are seeing. |
https://github.com/uopeydel/testdb use this project step test is run command docker build --pull --rm -f "dockerfile" -t testdb:latest "." docker run -d -p 1144:443/tcp -p 1188:80/tcp testdb:latest and go to url http://localhost:1188/api/Values/GetData It will show you error message
Then comment line below in "dockerfile"
then try to build docker and run again it will be work fine. ** please change ConnectionStrings before test |
Any ideas update? @smitpatel For now i think this is not relate just with Entity Framework Core May be it happen because .netcore 3.1 sdk I tried to create new docker file pushed today name "dockerfile.v2" You can run it by command
If i have 2 line of this code
And run this command
It will show this error message
If i remove this 2 line
It will work fine. |
@uopeydel - The error is certainly not in EF Core as we don't try to use those variables. It is likely limitation in SqlClient. Does your Sql Server installation has same locale settings as the one you are trying to use? |
No , i just want to use it in backend server. Thoes variables i set it for some lib can work fine with my language with out problem aboute a size and font. |
@uopeydel I'm transferring this to the dotnet runtime repo since the stack trace doesn't show anything data related. |
Tagging subscribers to this area: @cheenamalhotra, @David-Engel |
Hi @uopeydel Someone from our team will investigate and get back to you soon. |
SQL Server Management Studio 15.0.18206.0 and Microsoft SQL Server Enterprise (64-bit) For the collation it create by command update migration. I didn't set it. |
@uopeydel Thank you for the information you provided. Sorry for the delay. I will try your repo locally and keep you updated. Thanks, |
Hi @uopeydel , I got the chance to test your repro app locally. And yes, I can see the same exception even though my server collation is I comment out the following three lines in the docker file:
And adding the following three lines:
I can see my locale is changed for the docker container:
And if I build, run the docker file, and go to the url, the data can be returned without error. I also tried with other locales such as ko_KR.UTF-8 which doesn't show me the exception either. You can also play with different locales on your side to see whether you get the same behavior. I only get the exception when I set locale to Have you tried your application with other docker images or any Linux vm? Thanks, |
@karinazhou Aye, I ever tried. If I run without build( watch run ) it will show error after start like image below. When have those two variables. And if I run after build like above. It will show same thing with my locale |
@uopeydel That is strange if the application cannot work well with some locales. I will do more testing to dig this deeper. |
Hi @uopeydel , I did more tests on this one. Based on your repro app, I added two more routes to get the data directly using Microsoft.Data.SqlClient driver. You can find new ValuesController.cs here. Both
From our EventSource tracing log, I find that the command texts passing to SqlCommand are different when using Thai locale versus other working locale: // when using Thai locale
// when using other working locale
You can see that @ sign is missing which causes the SqlException you get. I think some locale issue happens when passing the parameters to the driver. Hi @ajcvickers , can someone from efcore side take a look at this issue to see why we are missing Thanks, |
Does it make sense to transfer the issue to EF Core repo based on @karinazhou 's response above? |
This look very similar to npgsql/efcore.pg#1508 (comment) |
Duplicate of #18831 |
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. |
Note from triage: we will prepare this for a 3.1 patch since it impacts all machines with Thai locale. |
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
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
And when I try to change var dataEmpNo into other name it will change error message
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
The text was updated successfully, but these errors were encountered: