简体   繁体   中英

Entity Framework with IBM DB2

We have a DB2 database which we are accessing via EF. 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
Message=CreateDatabase is not supported by the provider.
Source=EntityFramework InnerException:
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?

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.

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

Migration is not supported by IBM EF provider implementation.

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)
https://www.nuget.org/packages/System.Data.DB2.EntityFramework.Migrations/
You can find more info here
https://db2ef6migrations.codeplex.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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