IBM DB2 I系列数据库的实体框架提供程序错误 [英] Entity framework provider error with IBM DB2 I Series database

查看:120
本文介绍了IBM DB2 I系列数据库的实体框架提供程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,这是我的问题,我想以数据库优先的方式将实体框架与DB2 for I系列数据库一起使用,但是要成功建立连接确实很复杂.

首先,我试图使用"IBM DB2和IDS服务器"数据源创建一个实体数据模型,但是尽管我成功地建立了与LUW DB2的连接,但是我无法使用DB2 for I系列来完成此工作.,我尝试了446端口,说有许可证问题,9471产生了连接错误,8471一直等待,50000没有成功,我什至尝试不使用端口,但是没有用.

因此,我选择使用IBM DB2 for i数据源,该选项允许我进行连接,但是当我尝试使用Entity Framework 6.1.3时,我收到一条错误消息,告诉我EF 6.x与该版本不兼容

因此,我将EF降级为5.0,以尝试以任何方式创建实体模型,然后升级EF版本,但是,当我选择EF 5.0之后单击下一步时,实体数据模型向导消失了,然后显示数据库对象和设置,并且无法创建模型.

然后我确定我不需要edmx文件,因为该连接正在工作,所以我可以手动进行映射,所以我开始创建用于进行映射的类:

AppContext:

 公共类AppContext:DbContext{公共AppContext():base("connectionString"){}公共DbSet< Data>数据{get;放;}} 

数据:[表格(数据")]公开课数据{[Column("id")]public int ID {get;放;}

  [Column("name")]公共字符串名称{get;放;}} 

最后是测试:

 公共类程序{静态void Main(string [] args){使用(var ctx = new AppContext()){数据数据= new Data(){ID = 1,名称="A名称"};ctx.Datas.Add(data);ctx.SaveChanges();}}} 

我安装了EntityFramework.IBM.DB2 nuget版本6.0.7,并更改了Web.config以添加连接字符串,我在那里找到了一个名为"IBM.Data.DB2"的新提供程序并测试了连接,但是我开始有了我在第一次连接时遇到的问题与端口不同.

因此,我认为此提供程序必须是第一个连接的提供程序,并且我需要一个I系列的提供程序,因此我将提供程序更改为"IBM.Data.DB2.iSeries",然后再次尝试更改连接字符串中的某些参数,但是现在我收到此错误:

实体框架提供程序类型'IBM.Data.DB2.iSeries.iDB2Factory,IBM.Data.DB2.iSeries,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 9cdb2ebfb1f93a26'的'Instance'成员未返回从"System.Data.Entity.Core.Common.DbProviderServices"继承的对象.实体框架提供程序必须从此类继承,并且实例"成员必须返回提供程序的单例实例.这可能是因为提供程序不支持Entity Framework 6或更高版本.请参见

好,所以我的想法不多了,有人可以帮助我将实体框架与IBM DB2 for i系列一起使用吗?

谢谢

解决方案

要与DB2 iSeries连接,必须使用端口446连接.有一个虱子问题.您必须联系IBM以获得许可证:

ADM12008C产品"IBM数据服务器驱动程序包"没有已安装有效的许可证密钥,并且评估期已到期.未启用此产品特定的功能.如果你有已获得本产品的许可,请确保正确安装了许可证密钥.您可以使用db2licm命令安装许可证.执照可以从您的许可产品CD中获取文件.

点击此链接以获取更多信息:

https://www.ibm.com/developerworks/community/forums/html/topic?id=9a107d00-d814-440c-b438-faa4d020ae1a&ps=100

Ok here's my problem I want to use entity framework with a DB2 for I series database, in a database first way, but it has been really complicated to get a successful connection.

First I was trying to create an Entity Data model using the "IBM DB2 and IDS Servers" Data source but although I created a successful connection to a LUW DB2 I haven't been able to do it with the DB2 for I series, I have tried ports 446 it said there was a licence problem, 9471 generated a connection error, 8471 kept waiting and 50000 with no success, I even tried using no port, but it didn't work.

So I choosed to use the IBM DB2 for i data source, this option allows me to connect but when I try to use Entity Framework 6.1.3 I get an error telling me that EF 6.x is not compatible with this version.

So, I downgraded EF to version 5.0 to try to create the Entity Model any way and then upgrade the EF version, but, when I click on next after selecting EF 5.0 the Entity Data Model Wizard disappears before showing the database objects and settings and the model doesn't get created.

Then I decided I didn't need an edmx file I could do the mapping manually now that the connection is working so I started creating the classes to do the mapping:

AppContext:

public class AppContext: DbContext
{
    public AppContext() : base( "connectionString" )
    {
    }

    public DbSet<Data> Datas { get; set; }
}

Data: [Table("data")] public class Data { [Column("id")] public int Id { get; set; }

    [Column("name")]
    public string Name { get; set; }
}    

And finally the test:

public class Program
{
    static void Main(string[] args)
    {

        using (var ctx = new AppContext())
        {
            Data data = new Data() { Id = 1, Name = "A Name" };

            ctx.Datas.Add(data);
            ctx.SaveChanges();                
        }
    }
}

I installed the EntityFramework.IBM.DB2 nuget version 6.0.7 and changed my Web.config to add the connection string, I found there a new provider named "IBM.Data.DB2" and tested the connection but I began having the same problems I had with the first connection, with the different ports.

So I thought that this provider must be the one for the first connection and I needed the one for I series son I changed provider to "IBM.Data.DB2.iSeries" and tried again changing some parameters in the connection string but now I'm getting this error:

The 'Instance' member of the Entity Framework provider type 'IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

Here are my connection strings and providers from my Web.config:

<connectionStrings>
    <add name="DB2Connection" providerName="IBM.Data.DB2" connectionString="DataSource=192.168.1.54;UserID=XXXX;DefaultCollection=XXXX;Database=DB10000010; Password=XXXXXX;" />
    <add name="connectionString" providerName="IBM.Data.DB2.iSeries" connectionString="Server=192.168.1.54;UserID=XXXXX;Database=DB100000010; Password=XXXXX;" />
</connectionStrings>

<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" />
    <provider invariantName="IBM.Data.DB2.iSeries" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26" />
</providers>

I also found a new IBM I Access that is supposed to replace the old IBM DB2 i series for windows provider, but couldn't find a data source that works with it

Ok so I'm running out of ideas, Can anyone help me to use entity framework with IBM DB2 for i series?

Thanks

解决方案

To connect with DB2 iSeries you must connect using port 446. There is a licesing issue. You must contact IBM to obtain your license:

ADM12008C The product "IBM Data Server Driver Package" does not have a valid license key installed and the evaluation period has expired. Functions specific to this product are not enabled. If you have licensed this product, ensure the license key is properly installed. You can install the license using the db2licm command. The license file can be obtained from your licensed product CD.

Follow this link for more information:

https://www.ibm.com/developerworks/community/forums/html/topic?id=9a107d00-d814-440c-b438-faa4d020ae1a&ps=100

这篇关于IBM DB2 I系列数据库的实体框架提供程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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