Entity Framework for DB2

2019-02-17 06:16发布

I need to setup Entity Framework to work with a DB2 database. The main reason is to have nice object model instead of data sets and stored procedures.

The questions I have:

  1. Does the version of EF matter? I'd like to use v6 but so far I found only references to v4.
  2. Am I required to work with edmx file or can I also use DBContext (code first with an existing database)?
  3. How should the configuration file look like?

4条回答
该账号已被封号
2楼-- · 2019-02-17 06:34

Microsoft also has an Entity Provider for DB2, as part of their Microsoft Host Integration Server offering: http://msdn.microsoft.com/en-us/library/dn192288(v=bts.80).aspx

查看更多
倾城 Initia
3楼-- · 2019-02-17 06:48

Good news: there is a nuget package from IBM you can use: http://www.nuget.org/packages/EntityFramework.IBM.DB2/

Enjoy!

查看更多
再贱就再见
4楼-- · 2019-02-17 06:53

Other news about EF 6 support for DB2

You can find official nuget package for EF support here http://www.nuget.org/packages/EntityFramework.IBM.DB2/
but it does not support migrations.

If you need migration you can use also this package (in addition to previous package)
https://www.nuget.org/packages/System.Data.DB2.EntityFramework.Migrations/
You can find more info here
https://db2ef6migrations.codeplex.com/

查看更多
劳资没心,怎么记你
5楼-- · 2019-02-17 07:00

Regarding your questions:

  1. The standard data provider for DB2 doesn't support EF6, Code-First, Code-First Migrations. In case, your scenario requires these features, you should use third-party data providers.
  2. Yes, you could use the DbContext class with the standard data provider via Database-First approach, i.e. without its Code-First/Code-First Migrations functionality.
  3. It depends on the scenario and data provider being used. When working with the standard data provider it is enough to register the Entity Framework provider in the DbProviderFactories section of the config file for deploying the application. When working with EF6 and data providers, which support EF6, it is necessary to register the Entity Framework provider in the entityFramework section additionally (for example, please refer to this article ).

Please take a look at our data provider dotConnect for DB2 with Entity Framework support (including EF6):

http://www.devart.com/dotconnect/db2/features.html

http://www.devart.com/dotconnect/db2/docs/

The DataDirect also provides a data provider for DB2 - http://www.datadirect.com/support/product-documentation/product-information/support-matrices/datadirect-connect-for-ado-net/entity-framework-data-providers , however, it doesn't provide support for Entity Framework 6.

查看更多
登录 后发表回答