EntityFramework.IBM.DB2 cannot connect to db2
I am trying to connect to a db2 instance using EF6 and the new IBM Entity Framework data provider found here
added the provider to the application configuration:
<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>
and the connection string looks like this:
<add name="DB2" connectionString="Server=blah;Database=meh;Uid=user;Pwd=pword;" providerName="IBM.Data.DB2" />
I can instantiate the context, but when I try to run the request, it throws MethodAccessException
:
Attempt by method 'IBM.Data.DB2.EntityFramework.DB2ProviderServices.GetDbProviderManifestToken(System.Data.Common.DbConnection)' to access method 'IBM.Data.DB2.DB2Trace.Entity_CheckDB2Trace()' failed.
I have installed DB2 Version 10.5 fix pack 5
Any ideas as to what I might be doing wrong?
source to share
@Ramu, I recently started porting one of our legacy applications and started figuring out how to connect to IBM DB2 using Entity Framework 6. To answer directly your question - its not possible to work in VS 2015 as the IBM database adds -ins are only supported before VS 2013. We've contacted IBM and they have no idea if these add-ons will be released for VS 2015.
As a work around, I built my repository in VS 2013 and made it as a nuget package. I imported this package into a VS 2015 project. The packages are much cleaner now than giving hard links to dlls.
This is how I set up the environment
- Install IBM DB2 10.5 with Fix Pack 7. This should get the IBM Data 10.5 client data server.
- In the same installation package - install the IBM Database Add-ins for Visual Studio.
- Install the IBM Data Server 10.5 driver.
- Install EF Tools for VS2012 / VS2013
Go to Programs and Features — and always ensure that both IBM Data Server Clients and IBM Database Add-ins for VS must be at the same version, release, and patch level.
Hope it helps.
source to share