EntityFramework.IBM.DB2 can't connect to db2 - entity-framework

I'm trying to connect to a db2 instance using EF6 and the new IBM Entity Framework data provider found here
have added the provider to the app config:
<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 connection string looks like so:
<add name="DB2" connectionString="Server=blah;Database=meh;Uid=user;Pwd=pword;" providerName="IBM.Data.DB2" />
I can instantiate a context but when I try to run a query it throws a 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 the DB2 Version 10.5 Fix Pack 5
Any ideas as to what I might be doing wrong?

Turns out I had installed the 10.5.5 driver but it failed to be set as the default. After running the "Default DB2 and Database Client Interface Selection wizard" (found just by searching in the start menu) and setting the new one as the default it worked fine

#Ramu, I have recently started migrating one of our legacy applications and started figuring out how to connect to IBM DB2 using Entity Framework 6. To answer straight to your question - its not possible to work in VS 2015 as IBM database add-ins are supported only until VS 2013. We have contacted IBM and they have no idea if they are going to release these add-ins for VS 2015.
As a work around I built my repository in VS 2013 and made it as a nuget package. I have imported that package into my VS 2015 project. Now packages are much cleaner way of doing it than giving hard dll references.
This is how I setup the environment
Install IBM DB2 10.5 with Fix-pack 7. That should get IBM Data server Client 10.5.
On the same installation package – Install IBM Database Add-Ins for Visual Studio.
Install IBM Data server Driver 10.5.
Install EF Tools for VS2012/VS2013
Go to programs and features - and always make sure both IBM Data server client and IBM Database add-ins for VS should have same version, release and fix-pack level.
Hope this helps.

Related

How to get EF6 to work with DB2 in Visual Studio 2017

I've read numerous articles and posts here about getting Entity Framework to work with DB2 but all of them reference prior versions of Visual Studio. When I repeat the steps outlined (too many to remember at this point), I still do not have DB2 in the data providers list.
Has anyone gotten this to work in VS17 and, if so, can you walk me through what you did?
For registering IBM Database Add-Ins for Visual Studio 17, Visual Studio 2015 or earlier supported versions needs to be installed on the machine.
Steps:
Download and install IBM Data Server Driver Package
Download and install IBM Database Add-Ins for Visual Studio.
After successful installation of IBM Database Add-Ins, choose Start -> IBM Database Add-Ins for Visual Studio ->Register IBM Database Add-Ins.
This link has listed the steps needed for the add-in installation
https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/VSAIFORVS2017?lang=en
Note: Make sure to download same version and fix pack of DS Driver and VS IBM Database Add-In. I downloaded v11.1.3fp3 version for both installations and it's working for me.

Entity Framework Power Tools - cannot connect to Oracle

I have just installed Entity Framework Power Tools Beta 4 into Visual Studio 2013. I am running a .NET framework 4.5 project, using Entity Framework code first with an Oracle database. I have installed the latest ODP.NET from Oracle (version 12), including the EF drivers, and I have Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework referenced in my project.
This set up allows me to run my project and read and access data from the Oracle database. It all works fine. My problem is when I try to use the Entity Framework Power Tools. I can specify a connection using the Oracle database name and credentials, and the dialog says 'Test Connection succeeded'. However, after clicking the next button, I get the following error:
System.Data.ProviderIncompatibleException: The store provider factory type 'System.Data.OracleClient.OracleClientFactory' does not implement the IServiceProvider interface. Use a store provider that implements this interface.
I am confused because my project is able to use the installed ODP.NET as is to communicate with the Oracle database via Entity Framework. Most of the research I have done on the WWW suggests there should be a problem with versions and the contents of the web.config - but if this is the case surely I wouldn't be able to use EF with Oracle in my project without errors?
Is it just the case that the Power Tools do not work with Oracle?
Cheers!
Martin
As Christian says in his comment, you need to install ODP.NET as a provider that Power Tools can use. I did this by installing Oracle Developer Tools for Visual Studio.

SQL Server Compact 4.0 private deployment with Entity Framework 6.0 and NuGet

I have standardly setup WPF project with Entity Framework 6 and SQL Server Compact 4.0 installed.
When I build my project all the necessary files for SQL Server CE deployment are correctly copied to the Release folder, including System.Data.SqlServerCe.dll.
But running project on a machine without SQL Server Compact installed throws System.IO.FileLoadException.
In my development environment is the System.Data.SqlServerCe.dll loaded from GAC. I have found this reference, where the version numbers of dlls are explained: http://technet.microsoft.com/en-us/library/gg213826.aspx
I supposed that the version of System.Data.SqlServerCe.dll assembly form NuGet is 4.0.0.0.
So I have manually changed System.Data.SqlServerCe.dll reference in my project to 4.0.0.1 file form the Private folder and copied System.Data.SqlServerCe.dll 4.0.0.1 to the production machine.
I have changed app.config like that:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<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.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>
Now I get this exception on development machine:
The connection given is not of type 'SqlCeConnection'.
On production machine I get System.Data.Entity.Core.EntityException.
Is there any chance to get private deployment working with NuGet and EF 6? Or is it necessary to copy manually all the files in x86, amd64 folders?
The System.Data.Entity.Core.EntityException was already problem within my app, I also forgot to change DB name after deployment.
I have followed this guide and it is working now:
http://erikej.blogspot.sk/2013/11/entity-framework-6-sql-server-compact-4_25.html

how to add mysql data source in visual studio 2012 express for web

i'm trying to add mysql connection to my asp.net mvc 4 projects but i dont see it on the data source window.
after installing visual studio 2012 express for web i added mysql Connector/Net through nuget. i wanted to add new connection to mysql db but i did see mysql data source on the data source window list. after a search i realized that i have v6.6.4 and it supported from 6.6.5 so i uninstalled it from nuget and install 6.6.5 from mysql website(a complete install). it didnt helped.. i also tried to uninstall and reinstall it but it didnt change a thing.
how can i solve this?
Adding Connector/NET thru nuget will not install any of the visual studio integration stuff, for that you will need to run the Connector/NET installer (available at http://dev.mysql.com/downloads/connector/net/).
However due to legal constraints from Microsoft, integration with Visual Studio express editions is not possible (you'll need a non express version of visual studio).
The problem is that its an express version.
i installed a non express version and it worked.

Entity Framework 4.3 to Oracle: Web project works, NUnit doesn't

I've set up Entity Framework 4.3 against an Oracle database using DevArt's provider. I'm having a problem connecting to the database though through my unit test project in the NUnit 2.6 test runner. The funny thing is, I have an ASP.NET MVC 3 project connecting to it just fine. I've created an App.config in my class library unit test project and copied the entity connection string info to it. What am I missing?
Here's the entity connection info (same in Web.config and App.config):
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/Entities.MagellanDataModel.csdl|res://*/Entities.MagellanDataModel.ssdl|res://*/Entities.MagellanDataModel.msl;provider=Devart.Data.Oracle;provider connection string="User Id=theusername;Password=thepassword;Server=theTNSname"" providerName="System.Data.EntityClient" />
</connectionStrings>
Here's the exception info:
AppName.Tests.AccountRepositoryTests.GetByContactId:
System.Data.EntityException : The underlying provider failed on Open.
----> System.InvalidOperationException : Can not obtain Oracle client information
from registry. Make sure that Oracle Client Software is installed, or use
Direct mode of connecting to server.
NOTE: Both the web and unit test assemblies are set to compile to Any CPU. I'm running 32 bit Oracle 10g database on 64 bit Windows 7. I found a post seems to indicate that it's related to the Platform needing to be x86, but my web project is set to Any CPU and it's working fine.
I had a similar problem: Win7 64-bit DevArt with 32bit Oracle.
Works well with Any CPU for web projects but fails for console and unit tests projects. I fixed it (or work around it) by setting x86 for tests and console projs in Debug mode.
I had the same issue. For me this problem is resolved by unchecking 'Prefer 32-bit' check box in Project properties -> Build -> below Platform Target. My Platform Target was set to 'Any CPU'.