DB2 实体框架 [英] Entity Framework for DB2

查看:17
本文介绍了DB2 实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置实体框架以使用 DB2 数据库.主要原因是拥有良好的对象模型而不是数据集和存储过程.

我的问题:

  1. EF 的版本重要吗?我想使用 v6,但到目前为止我只找到了对 v4 的引用.
  2. 我是否需要使用 edmx 文件,或者我也可以使用 DBContext(代码优先使用现有数据库)?
  3. 配置文件应该是什么样子的?

解决方案

关于您的问题:

  1. DB2 的标准数据提供程序不支持 EF6、Code-First、Code-First 迁移.如果您的场景需要这些功能,您应该使用第三方数据提供商.
  2. 是的,您可以通过 Database-First 方法将 DbContext 类与标准数据提供程序一起使用,即没有其 Code-First/Code-First Migrations 功能.
  3. 这取决于使用的场景和数据提供者.使用标准数据提供程序时,只需在配置文件的 DbProviderFactories 部分注册实体框架提供程序即可部署应用程序.使用 EF6 和支持 EF6 的数据提供程序时,需要在 entityFramework 部分额外注册实体框架提供程序(例如,请参阅 这篇文章).

请查看我们的数据提供程序 dotConnect for DB2 支持实体框架(包括 EF6):

http://www.devart.com/dotconnect/db2/features.htmlp>

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

DataDirect 还为 DB2 提供数据提供者 - http://www.datadirect.com/support/product-documentation/product-information/support-matrices/datadirect-connect-for-ado-net/entity-framework-data-providers,但是,它不提供对 Entity Framework 6 的支持.

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?

解决方案

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.

这篇关于DB2 实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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