简体   繁体   English

IBM DB2的实体框架

[英]Entity Framework with IBM DB2

We have a DB2 database which we are accessing via EF. 我们有一个通过EF访问的DB2数据库。 We are able to connect to the database and do read & write operations as part of this. 在此过程中,我们能够连接到数据库并执行读写操作。

Now the plan is to initialize the DB using 现在的计划是使用

Database.SetInitializer(new CreateDatabaseIfNotExists<CustomContext>())

This throws out an error saying 这抛出一个错误说

HResult=-2146232032 的HResult = -2146232032
Message=CreateDatabase is not supported by the provider. 提供程序不支持Message = CreateDatabase。
Source=EntityFramework InnerException: Source = EntityFramework InnerException:
System.Data.Entity.Core.ProviderIncompatibleException System.Data.Entity.Core.ProviderIncompatibleException

Previously we were connecting with 以前我们与

Database.SetInitializer(new NullDatabaseInitializer<CustomContext>());

and this was working fine. 而且工作正常。

The question is has any one tried creating a new DB2 database from within EF? 问题是是否有人尝试从EF中创建新的DB2数据库?

You cannot do that .That is Known limitation of the provider. 不能那样做 。这是提供者的已知限制。

General limitations: 一般限制:

Only database-first scenarios are supported: any database object that you reference in Entity Framework must first exist in the database. 仅支持数据库优先方案:您在Entity Framework中引用的任何数据库对象必须首先存在于数据库中。

Invocation of store-specific functions is not supported. 不支持特定于商店的功能的调用。

Trusted context connection properties that you set in the Server Explorer Add Connection dialog are not passed to Entity Framework connections. 您在“服务器资源管理器”的“添加连接”对话框中设置的可信上下文连接属性不会传递给实体框架连接。

You can read it here : Limitations to Microsoft Entity Framework support 您可以在此处阅读: Microsoft Entity Framework支持的局限性

Migration is not supported by IBM EF provider implementation. IBM EF提供程序实现不支持迁移。

If you need DB2 migration support you can use this package that implements only migration (so you can use it in addition to IBM DB2 EF Provider) 如果需要DB2迁移支持,则可以使用仅实现迁移的此软件包(因此,除了IBM DB2 EF Provider之外,还可以使用它)
https://www.nuget.org/packages/System.Data.DB2.EntityFramework.Migrations/ https://www.nuget.org/packages/System.Data.DB2.EntityFramework.Migrations/
You can find more info here 您可以在这里找到更多信息
https://db2ef6migrations.codeplex.com/ https://db2ef6migrations.codeplex.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM