Generating an EDMX from a DB2 Database

c# db2 edmx entity-framework-6


In order to read from and write to a DB2 database, I'm attempting to use VS2013 to build an EDMX file. The exact steps I took to create the EDMX from my SQL tables still apply (Right click on project -> Add New Item -> ADO.NET Entity Data Model -> EF Designer from database -> Not using SQL this time so: new connection -> Change data source), but DB2 is not a choice under the Data Source heading. I only have two options for SQL.

a data source

Following some research both here and in other places, it appears that EF wasn't actually set up to perform this until a plugin for EF6 was released. I therefore installed EntityFramework via Nuget. I had hoped that IBM.DB2 version 6.0.3 would add anything to my Data Source box so I could select a DB2 database, but nothing changed.

I'm going to try to provide as much information about my system as I can here, so if I ramble—which I often do—I apologize in advance.

I'm running VS2013 Pro on Windows 7. My ODBC connection is set up and has been performing well for years. I can check my connection to both Test and Production DB2 in the ODBC Manager, and it connects without a hitch.

I use the IBM DB2 ODBC Driver, which appears to be version 10.5.500 (although I'm not entirely sure if I'm looking in the appropriate place to acquire that version number). The ODBC Data Source Administrator is version 6.1.7601.17632.

Additionally, I can use Access to open an ODBC connection to the DB2 databases and retrieve the tables and their contents.

With the connection string set up, which I suppose utilizes the same ODBC connection, I can also put SQL statements right into my code. These statements accept data from SQL and call stored procedures linked to the DB2 tables to write, update, and remove information.

Last but not least, it appears that a former coworker was able to make this work. I've loaded his code, and when I open the EDMX, all the tables are nicely represented graphically. However, I encounter a problem when I attempt to select Update from Database:

Mistake Message

He is sadly no longer employed by the company, and his computer isn't in a state where I can look at it.

So it appears that this is something that can be accomplished and that my machine is almost ready for this, barring the absence of a component that would enable me to add the DB2 type data source to the first image above, allowing me to choose it, enter the necessary information, and continue.

Any assistance would be greatly appreciated.

4/11/2016 12:31:35 PM

Accepted Answer

Installing IBM's drivers as well as a Visual Studio Add-in is required in order to use Entity Framework and Visual Studio (to make DB2 show up in the dropdown of data providers and create an EDMX properly). The configuration we employ to speak with DB2 z/os is as follows. I'm not sure if these drivers are compatible with DB2 Linux/Unix/Windows.

The client version 10.5 fix pack 7 is available at the URL above. This is how I installed Visual Studio 2013 and 2015 on Windows 7 and 8.1. (have not tested on a Windows 10 development machine).

What you will need to download and install is listed below.

  1. package for data server drivers (Windows)
  2. Visual Studio add-ons for databases

Additionally, a licensing file is required (your DBA should be able to provide this for you, or at least download one using their IBM login)

Install the add-ins following the data server drivers. duplicate the licensing file toC:\Program Files\IBM\IBM DATA SERVER DRIVER\license

Still required is the EntityFramework. If you want to use EF6, you must use the IBM.DB2 nuget package because the Visual Studio Add-ins alone are only compatible with EF5.

4/13/2016 6:13:43 PM

Popular Answer

Thank you for your reply.

I found exactly what I was looking for in the Database Add-ins.

Since I had already completed part 1 of your inquiry, I was able to move on to part 2, but first I had to update my drivers to match the version I had used to install the Add-ins.

I upgraded my drivers after downloading version 10.5, which allowed me to install the Add-In and proceed with creating my EDMX.

Many thanks for your assistance.

Related Questions


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