Reputation: 85
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?
Upvotes: 1
Views: 1441
Reputation: 6491
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/
Upvotes: 0
Reputation: 65870
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
Upvotes: 2