SSIS - Entity Framework - {Model}.resource.dll 丢失

SSIS - Entity Framework - {Model}.resource.dll is missing

我正在编写一个带有脚本组件的 SSIS 包。在此脚本组件中,我试图建立一个 Entity Framework 连接,但出现以下错误:

Could not load file or assembly '{Model}.resource.dll' or one of its dependencies error

{Model} 是包含我的 EF6 代码优先模型的 dll。我没有任何可用的 {Model}.resource.dll。

如果我 运行 在控制台应用程序中使用相同的代码,它可以正常工作并且没有 .resource.dll

我使用 DBConfiguration 删除 app.config 文件,因为 SSIS 不支持它。

public class ModelConfig : DbConfiguration
{
    public ModelConfig()
    {
        this.SetDefaultConnectionFactory(new System.Data.Entity.Infrastructure.LocalDbConnectionFactory("mssqllocaldb"));

        this.SetProviderServices("System.Data.SqlClient",
           System.Data.Entity.SqlServer.SqlProviderServices.Instance);

    }
}

找到问题了。

SSIS 正在向线程添加区域设置信息。 Entity Framework 存在语言环境信息错误。

这有助于:

public ScriptMain()
{
    System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
    System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
}