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.