已升级 ServiceStack.OrmLite.SqlServer。现在收到关于 System.Text.Encoding.CodePages 的错误

Upgraded ServiceStack.OrmLite.SqlServer. Getting an error about System.Text.Encoding.CodePages now

我继承了一个最初用.NetCore 2.0 编写的项目。我们使用的 ServiceStack.OrmLite.SqlServer.Core 版本是 1.0.43。我升级了 NuGet 中的所有内容,所以 ServiceStack 现在是 5.4.0。

现在的问题是,当我尝试 运行 我的代码时:

var dbFactory = new OrmLiteConnectionFactory(dbConnection.ConnectionString, SqlServerDialect.Provider);
using (var db = dbFactory.Open())

我收到一个错误

System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我在深入了解 ServiceStack 引用 4.5 版代码页的依赖关系中看到。

我不确定我需要做什么来解决这个问题...

如果它是一个 .NET Core 项目,那么它不应该使用任何 *.Core 包,在 v5 之后,仅适用于 运行 ASP.NET Core Apps on the .NET Framework.

从 v5 开始,主要包,例如:ServiceStack.OrmLite.SqlServer 包含 .NET Standard 2.0 和 .NET 4.5 Framework 版本。

鉴于它引用了错误的包,我将卸载所有 ServiceStack 包并只安装 non.Core ServiceStack 包。