2

I have been struggling for this one for a day or so, and finally have to turn it over to the experts.

I built a class library in .Net 4.5.2 which is doing some work with entity framework v6. It works lovely when I bring it into a console app (once I brought over the app.config and added entity framework in the references).

I wanted to use the library in my SSIS script tasks. After loading the library in the GAC, Since I know that the script won't have access to the config file (same problem as console app), I pass in the connection string dynamically....(example)

partial class TemplateEntities
{
  public TemplateEntities( string nameOrConnectionString )
    : base( nameOrConnectionString )
  {
  }
}

However I ran into problems trying to load EntityFramework.

I followed these instructions to dynamically load the assembly, however it started complaining about

{"Schema specified is not valid. Errors: \r\nImportModel.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. S ee http://go.microsoft.com/fwlink/?LinkId=260882 for more information."}

My thought is that alright, it needs other config junk...so I gave it some code config

[DbConfigurationType(typeof(EFCodeConfig))]
public partial class importEntities : DbContext
{
    public importEntities(string connectionString) : base(connectionString) {
        //var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
    }
}

public class EFCodeConfig : DbConfiguration
{
    public EFCodeConfig()
    {
        this.SetDefaultConnectionFactory(new System.Data.Entity.Infrastructure.SqlConnectionFactory());
        this.SetProviderServices("System.Data.SqlClient", System.Data.Entity.SqlServer.SqlProviderServices.Instance);

    }
}

Now I am getting the following error:

InnerException: HResult=-2146233054 Message=Could not load type 'System.Data.Entity.SqlServer.SqlProviderServices' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Source=ImportService TypeName=System.Data.Entity.SqlServer.SqlProviderServices StackTrace: at ImportServices.EFCodeConfig..ctor() InnerException:

I know that EntityFramework.SqlServer.dll is in my library debug directory, but isn't getting loaded in the scripts list of modules. I have tried to intercept the resolve request and load it, but the resolve request never comes for this dll. I even try just straight up loading the assembly anyways and that doesn't work.

I am at wits end now, I have tried everything I can think of or google. Thanks.

patrickb19
  • 33
  • 4
  • please, [check](http://stackoverflow.com/a/6240518/225389) if SSIS script task uses matches (not smaller than should also work) .net version that you use to compile your library. also please [check](http://stackoverflow.com/q/3460982/225389) if verson of EntityFramework.SqlServer.dll matches SSIS script task .net version – Chizh Feb 19 '17 at 01:24
  • .Net 4.5 in script task vs .Net 4.5.2, I downgraded my class library to 4.5.2. Entity framework (and the EntityFramework.SqlServer.dl was built in v4.0.30319). Didn't work. Good try though. – patrickb19 Feb 19 '17 at 01:36
  • downgraded my class library to 4.5.2? did you mean 4.5? – Chizh Feb 19 '17 at 01:42
  • Opps yes, downgraded class to 4.5 – patrickb19 Feb 19 '17 at 02:05
  • Did you have any luck making EF work in a SSIS script task? – Andrew May 25 '18 at 22:27
  • Any luck? Trying to do the same! – Jon Nov 29 '18 at 17:51

0 Answers0