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.

Globalization Invariant Mode is not supported

See original GitHub issue

when I use Microsoft.EntityFrameworkCore.SqlServer Version 3.0.0, got an error as follows:

Application startup exception: System.NotSupportedException: Globalization Invariant Mode is not supported.
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at Microsoft.Data.SqlClient.SqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass18_0.<Exists>b__0(DateTime giveUp)
   at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_0`2.<Execute>b__0(DbContext c, TState s)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, Func`2 operation, Func`2 verifySucceeded, TState state)
   at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func`2 operation)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists(Boolean retryOnNotExists)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists()
   at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreated()
   at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated()

Additional context

Microsoft.EntityFrameworkCore.SqlServer Version 3.0.0 Microsoft.Data.SqlClient version: 1.0.19249.1 Target framework: (.NET Core 3.0) Operating system: Docker Alpine

Solution

fixed with add the follows to the dockerfile

RUN apk add icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

more details: https://www.abhith.net/blog/docker-sql-error-on-aspnet-core-alpine/ reference sample project: https://github.com/WeihanLi/ActivityReservation

Copied from https://github.com/aspnet/EntityFrameworkCore/issues/18025

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:34
  • Comments:26 (15 by maintainers)

github_iconTop GitHub Comments

11reactions
Wraith2commented, Oct 10, 2019

It isn’t supported for a good technical reason. If you want to use sqlclient in docker you’ll need to make sure you have the icu libraries installed. I don’t know what you’re expecting anyone here to do to change that.

5reactions
80dBcommented, Oct 10, 2019

It isn’t supported for a good technical reason. If you want to use sqlclient in docker you’ll need to make sure you have the icu libraries installed. I don’t know what you’re expecting anyone here to do to change that.

I think the major issue is this one: https://github.com/dotnet/SqlClient/issues/220#issuecomment-535628814 (e.g. it worked for many people without the change in the docker file (e.g. without installing icu))

And that it’s not listed as a breaking change on this page (yet): https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes

Just helping nxtx 😉 And helping nxtx a bit more, the temporary solution isn’t temporary. It’s the (only) permanent solution. Add the 3 lines (or 2 if you remove the comment) just before the ENTRYPOINT part in your docker file and it’ll work just fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.NET Core application running in Linux Docker container ...
I am attempting to connect to two MSSQL servers using SQL Authentication. When I run my application on my machine with dotnet run...
Read more >
Globalization config settings - .NET
Determines whether a .NET Core app runs in globalization-invariant mode without access to culture-specific data and behavior.
Read more >
How to detect Globalization-Invariant mode in .NET
Some libraries don't work when the application is running using Globalization-Invariant mode. This mode disabled all globalization features ...
Read more >
Culture creation and case mapping in globalization ...
Globalization-invariant mode is used for apps that don't required any globalization support. That is, the app runs without access to culture- ...
Read more >
Parameter 'Culture' is an invalid culture identifier
The Invariant Mode can be turned on in multiple ways with the most common being ... Only the invariant culture is supported 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