IBM DB2 Entityframework issue

db2 entity-framework-6 visual-studio-2015

Question

Please help if you know how to fix this issue.

VS 2015 Nuget Package manager Installed - EntityFramework 6.1.3 + IBM DB2 EntityFramework 6.0.6 EDMX file created from database.

Getting error on

public partial class dbb1Entities : DbContext
{
    public dbb1Entities()
        : base("name=dbb1Entities"){}
}

Error:

The Entity Framework provider type 'IBM.Data.DB2.EntityFramework.DB2ProviderServices, IBM.Data.DB2.EntityFramework, Version=10.5.5.6, Culture=neutral, PublicKeyToken=7c307b91aa13d208' registered in the application config file for the ADO.NET provider with invariant name 'IBM.Data.DB2' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

Web.config details

<configSections>    
 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->      
</configSections>      
<connectionStrings>        
<add name="dbb1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=IBM.Data.DB2;provider connection string=&quot;Database=dbb1;User ID=Dev;Password=AABCDEF;CurrentSchema=bx00001;Server=db2:50000&quot;" providerName="System.Data.EntityClient" />      
</connectionStrings>      
<entityFramework>        
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />       
<providers>          
<provider invariantName="IBM.Data.DB2" type="IBM.Data.DB2.EntityFramework.DB2ProviderServices, IBM.Data.DB2.EntityFramework, Version=10.5.5.6, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />        
</providers>     
</entityFramework>

Machine Config details

<add name="IBM DB2 .NET Data Provider 10.5.0" invariant="IBM.Data.DB2.10.5.0" description="IBM DB2 Data Provider 10.5.0 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.10.5.0, Version=10.5.0.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM DB2 .NET Data Provider 10.5.7" invariant="IBM.Data.DB2.10.5.7" description="IBM DB2 Data Provider 10.5.7 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.10.5.7, Version=10.5.7.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM DB2 .NET Data Provider 11.1.1010" invariant="IBM.Data.DB2.11.1.1010" description="IBM DB2 Data Provider 11.1.1010 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.11.1.1010, Version=11.1.1010.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM DB2 .NET Data Provider" invariant="IBM.Data.DB2" description="IBM DB2 Data Provider for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM DB2 .NET Data Provider 10.5.6" invariant="IBM.Data.DB2.10.5.6" description="IBM DB2 Data Provider 10.5.6 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.10.5.6, Version=10.5.6.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

1
2
4/4/2017 4:57:30 PM

Popular Answer

I was having the exact same issue with a similar setup VS2015, EntityFramework 6.2, EntityFramework.IBM.DB2 6.1, but I managed to fix the problem.

I noticed a reference to .net 4.6.1, and after changing my target framework from 4.5.1 to 4.6.1 the issue was solved!

Posted below the IBM application versions/setup that worked for me.

Machine.config

<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  <add name="IBM DB2 .NET Data Provider" invariant="IBM.Data.DB2" description="IBM DB2 Data Provider for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
  <add name="IBM Informix .NET Data Provider" invariant="IBM.Data.Informix" description="IBM Informix Data Provider for .NET Framework 4.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
  <add name="IBM DB2 .NET Data Provider 10.5.6" invariant="IBM.Data.DB2.10.5.6" description="IBM DB2 Data Provider 10.5.6 for .NET Framework 4.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.10.5.6, Version=10.5.6.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
  <add name="IBM Informix .NET Data Provider 10.5.6" invariant="IBM.Data.Informix.10.5.6" description="IBM Informix Data Provider 10.5.6 for .NET Framework 4.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix.10.5.6, Version=10.5.6.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />

App.config

  <entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
  <provider invariantName="IBM.Data.DB2" type="IBM.Data.DB2.EntityFramework.DB2ProviderServices, IBM.Data.DB2.EntityFramework, Version=10.5.5.6, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
</providers>

Installed IBM Applications Installed IBM Versions

1
1/4/2019 4:40:51 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow