首页新闻找找看学习计划

遭遇 EF Core 错误: "Globalization Invariant Mode is not supported"

0
悬赏园豆:30 [已解决问题] 解决于 2020-03-22 20:23

在一个 .NET Core 3.1 项目中,Entity Framework 3.0 报下面的错误,请问如何解决?

System.NotSupportedException: Globalization Invariant Mode is not supported.
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at Microsoft.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
dudu的主页 dudu | 高人七级 | 园豆:39361
提问于:2020-03-22 18:36
< >
分享
最佳答案
0

如果是 asp.net core 3.0 程序运行在 docker 中并无法与 db 连接, 似乎是一个已知问题...

https://github.com/dotnet/SqlClient/issues/220

我在此处找到了类似问题说明. 希望有所帮助

收获园豆:30
Dennis.Wu | 菜鸟二级 |园豆:221 | 2020-03-22 19:26

受此启发,将 Dockerfile 中基于 alpine 系统的镜像改为基于 Debian 的 mcr.microsoft.com/dotnet/core/aspnet:3.1 镜像,问题就消失了。

dudu | 园豆:39361 (高人七级) | 2020-03-22 19:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册