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

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

问题描述

我需要将Entity Framework设置为使用DB2数据库。主要原因是拥有漂亮的对象模型而不是数据集和存储过程。



我有以下问题:


  1. EF的版本是否重要?我想使用v6,但到目前为止,我发现只有对v4的引用。

  2. 我需要使用edmx文件,还可以使用DBContext(代码首先与现有的数据库) ?

  3. 配置文件应该如何?


解决方案

关于您的问题:


  1. DB2的标准数据提供程序不支持EF6,代码优先,代码优先迁移。如果您的方案需要这些功能,您应该使用第三方数据提供程序。

  2. 是的,您可以通过Database-First方法将DbContext类与标准数据提供程序一起使用,即没有其代码优先/代码优先迁移功能。

  3. 这取决于正在使用的场景和数据提供者。当使用标准数据提供者时,只需在配置文件的DbProviderFactories部分注册Entity Framework提供程序即可部署应用程序。
    当使用支持EF6的EF6和数据提供者时,需要在实体框架部分中注册实体框架提供者(例如,请参阅这篇文章)。

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



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



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天全站免登陆