Page 1 of 1

Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Sat 29 Mar 2014 15:24
by Dennis Wanke
Static method EntityFramework!Database.Exists(DbConnection) returns true when ObjectContext.DatabaseExists() for a context created with the same database connection returns false (direct mode, a user with an empty schema exists in the database). Tried it with all different values of DatabaseScript.Schema.DeleteDatabaseBehaviour with the same result.

In fact, Database.Exists() calls ObjectContext.DatabaseExists() internally for a specially constructed "empty" context:

Code: Select all

DbModelBuilder().Build(connection).Compile().CreateObjectContext<ObjectContext>(connection)
As no StoreItemCollection is supplied in this case, the only viable option would be to determine if user's schema contains at least one database object (which probably corresponds to DeleteDatabaseBehaviour.AllSchemaObjects or DeleteDatabaseBehaviour.Schema).

Similar issue: http://forums.devart.com/viewtopic.php?f=1&t=29260

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Wed 02 Apr 2014 12:36
by Shalex
We will investigate the possibility of implementing the following behaviour: Database.Exists(DbConnection) should return true if DatabaseScript.Schema.DeleteDatabaseBehaviour = AllSchemaObjects and at least one table or sequence or trigger exists in the current schema (specified in the User Id or set with Initialization Command connection string parameter).

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Wed 09 Apr 2014 14:14
by Shalex
The Database.Exists(DbConnection) functionality is supported: the method returns true if DatabaseScript.Schema.DeleteDatabaseBehaviour = AllSchemaObjects and at least one table or sequence exists in the current schema (specified in User Id or set with Initialization Command connection string parameter). We will notify you when the corresponding build of dotConnect for Oracle is available for download.

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Thu 10 Apr 2014 14:13
by Shalex
New build of dotConnect for Oracle 8.3.135 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=29348.

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Fri 11 Apr 2014 10:04
by Dennis Wanke
The issue is still reproducible with 8.3.135 on Oracle 12c.

Database.Exists() returns true after Database.Delete() has been called for the same connection. ObjectContext.DatabaseExists() returns false in this case (as it should). The problem is probably caused by system-generated sequences that are (correctly) ignored when using ObjectContext.DatabaseExists() but still accounted with Database.Exists().

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Tue 15 Apr 2014 10:41
by Shalex
Thank you for your report. We have reproduced the issue and are working on it.

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Thu 24 Apr 2014 14:41
by Shalex
The following issues are fixed in the new 8.3.146 build of dotConnect for Oracle:
  • The behaviour is changed: now Database.Delete(DbConnection), when config.DatabaseScript.Schema.DeleteDatabaseBehaviour = AllSchemaObjects, removes sequences in the current schema of Oracle 12c only if config.DatabaseScript.Column.NumericIdentityBehavior = ExplicitTriggerAndSequence
  • The behaviour is changed: now Database.Exists(DbConnection), when config.DatabaseScript.Schema.DeleteDatabaseBehaviour = AllSchemaObjects, checks an existence of sequences in the current schema of Oracle 12c only if config.DatabaseScript.Column.NumericIdentityBehavior = ExplicitTriggerAndSequence
  • The bug with checking an existence of system-generated sequences by Database.Exists(DbConnection), when config.DatabaseScript.Schema.DeleteDatabaseBehaviour = AllSchemaObjects and config.DatabaseScript.Column.NumericIdentityBehavior = ExplicitTriggerAndSequence, is fixed
Please try the new build and notify us about the result.

Re: Inconsistent behavior of ObjectContext.DatabaseExists() and EntityFramework!Database.Exists(DbConnection)

Posted: Thu 24 Apr 2014 16:59
by Dennis Wanke
I confirm the behavior is now consistent.