我正在尝试使用 VS2013 创建一个 EDMX 文件,以便可以从 DB2 数据库读取/写入.我经历了与从我的 SQL 表创建 EDMX 相同的过程(右键单击项目 -> 添加新项目 -> ADO.NET 实体数据模型 -> 数据库中的 EF 设计器 -> 这次不使用 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.
数据源
因此,在对这里和其他一些地方进行了一些调查之后,在 EF6 插件问世之前,似乎 EF 并未真正设置为执行此操作.因此,我使用 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.
我在使用 VS2013 专业版的 Windows 7 上.我有一个 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,我使用的是 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)
我还可以进入 Access 并使用 ODBC 连接连接到 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.
我还可以使用连接字符串设置(我假设使用相同的 ODBC 连接)将 SQL 语句直接写入我的代码,并从 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.
所以感觉这是可以完成的事情,而且我的计算机几乎已设置为可以执行此操作...除了我缺少的一些东西,它允许我首先将那个 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
您还需要一个许可文件(您的 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 FilesIBMIBM DATA SERVER DRIVERlicense
Install the data server drivers first, then the add-ins. Copy your license file to C:Program FilesIBMIBM DATA SERVER DRIVERlicense
如果您希望使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!