从DB2数据库生成EDMX [英] Generating an EDMX from a DB2 Database

查看:107
本文介绍了从DB2数据库生成EDMX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VS2013创建一个EDMX文件,以便我可以从DB2数据库读取/写入。我从我的SQL表中创建EDMX的过程(右键点击项目 - >添加新项目 - > ADO.NET实体数据模型 - >从数据库中获取EF Designer - >此时不使用SQL:新连接 - >更改数据源),但在数据源选项中,DB2不可用。我有2个SQL选项,就是这样。

I'm trying to create an EDMX file using VS2013 so I can read/write from a DB2 Database. I go through the same process as creating the EDMX from my SQL tables (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 in the Data Source option, DB2 is not available. I have 2 SQL options and that's it.

数据源

所以在和其他一些地方一起进行一些调查之后,看起来EF似乎并没有设置直到插件为EF6出来。所以使用Nuget我已经安装了EntityFramework.IBM.DB2版本6.0.3,希望能够添加一些数据源区域,这样我可以选择一个DB2数据库,但仍然没有。

So after doing some investigating around here along with some other places, it looks like EF wasn't actually setup to do this until a plugin for EF6 came out. So using Nuget I have installed EntityFramework.IBM.DB2 version 6.0.3 hoping that would add something to my Data Source area allowing me to choose a DB2 database but still nothing.

我会尝试给我这么多的关于我的系统的信息,因为我知道,如果我匆忙...我倾向于做...提前抱歉。

I'm gonna try to give as much info about my system here as I know so if I ramble...which I tend to do...sorry in advance.

我在Windows 7上使用VS2013 Pro版本。我有一个ODBC连接设置,它已经运行了很多年。我可以进入ODBC管理器并测试我的连接到测试和生产DB2,它连接很好。

I'm on Windows 7 using VS2013 Pro edition. I have an ODBC connection setup and it's been working great for years. I can go into the ODBC Manager and test my connection to both Test and Production DB2 and it connects just fine.

ODBC数据源管理器是版本6.1.7601.17632和I '使用IBM DB2 ODBC驱动程序...看起来像10.5.500版本(虽然我不是100%肯定我是否正确的地方找到该版本号)

The ODBC Data Source Administrator is version 6.1.7601.17632 and I'm using the IBM DB2 ODBC Driver...looks like it's version 10.5.500 (although I'm not 100% sure if I'm looking in the right place to get that version number)

我也可以使用ODBC连接进入Access并连接到DB2数据库,并带回表格及其数据。

I can also go into Access and connect to the DB2 databases using the ODBC connection and bring back the tables and their data.

我也可以将SQL语句直接写入我的代码中,并使用连接字符串设置(我假定使用相同的ODBC连接)并从SQL读取数据,并调用连接到这些DB2表的存储过程以写入/更新/删除。

I can also write SQL statements directly into my code with the connection string setup (that I assume uses that same ODBC connection) and reads data from SQL and calls Stored Procedures connected to those DB2 tables to write/update/delete.

最后,似乎以前的同事能够做到这一点。我加载了他的代码,当我拉起EDMX,我得到所有表的漂亮的图形显示。但是当我尝试点击从数据库更新时,我收到一个错误:

Lastly, it seems like a previous coworker was able to make this work. I have loaded his code and when I pull up the EDMX, I get the nice graphical display of all the tables. But when I try to click Update from Database, I get an error:

错误消息

可惜,他不再是公司,他的电脑不能在一个条件下,看看它。

Sadly, he is no longer with the company and his computer is not in a condition where I can take a look at it.

所以感觉这是可以完成的事情,我的电脑几乎被设置为这样做...除了我的东西, m丢失,这将允许我将该DB2数据源添加到上面的第一个图像,以便我可以选择它,将凭据放入并移动。

So it feels like this is something that can be done and that my computer is almost setup to do this...with the exception of something I'm missing that will allow me to add that DB2 type data source to that first image above so I can select it, put the credentials in and move on.

任何帮助将真正感谢...

Any help will be truly appreciated...

推荐答案

为了使用Entity Framework和Visual Studio ...,您需要安装IBM的驱动程序以及Visual Studio加载项(以使DB2显示在数据提供者的下拉列表中并正确创建EDMX)。以下是我们用于与DB2 z / os通信的设置。我不确定这些驱动程序是否与DB2 Linux / Unix / Windows兼容。

In order to use Entity Framework and Visual Studio... you need to install IBM's drivers as well as a Visual Studio Add-in (to make DB2 show up in the dropdown of data providers and create an EDMX properly). The following is the setup we use to communicate with DB2 z/os. I am not sure whether or not these same drivers work with DB2 Linux/Unix/Windows.

http://www-01.ibm.com/support/docview.wss?uid=swg24041453

以上链接适用于客户端版本10.5修订包7.我已经使用它来在Windows 7 / 8.1中安装Visual Studio 2013和Visual Studio 2015(未在Windows 10开发机器上测试) 。

The above link is for the client version 10.5 fix pack 7. I have used this to setup both Visual Studio 2013 and Visual Studio 2015 in Windows 7/8.1 (have not tested on a Windows 10 development machine).

以下是您需要下载并安装

Here's what you will need to download and install


  1. 数据服务器驱动程序包(Windows)

  2. Visual Studio的数据库加载项

您还需要许可证文件(您的DBA应该能够为您提供此功能,或至少使用其IBM登录名下载)

You will also need a license file (your DBA should be able to provide this for you, or at least download one using their IBM login)

首先安装数据服务器驱动程序,然后再将加载项。将您的许可证文件复制到 C:\Program Files\IBM\IBM DATA SERVER DRIVER\license

Install the data server drivers first, then the add-ins. Copy your license file to C:\Program Files\IBM\IBM DATA SERVER DRIVER\license

如果您希望使用EF6,您仍然需要EntityFramework.IBM.DB2 nuget软件包,因为Visual Studio加载项本身仅与EF5兼容

You will still need the EntityFramework.IBM.DB2 nuget package if you wish to use EF6, as the Visual Studio Add-ins by themselves are only compatible with EF5

这篇关于从DB2数据库生成EDMX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆