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

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

Postby Dennis Wanke » Sat 29 Mar 2014 15:24

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
Dennis Wanke
 
Posts: 57
Joined: Tue 11 Mar 2014 07:49

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

Postby Shalex » Wed 02 Apr 2014 12:36

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).
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44

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

Postby Shalex » Wed 09 Apr 2014 14:14

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.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44

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

Postby Shalex » Thu 10 Apr 2014 14:13

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.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44

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

Postby Dennis Wanke » Fri 11 Apr 2014 10:04

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().
Dennis Wanke
 
Posts: 57
Joined: Tue 11 Mar 2014 07:49

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

Postby Shalex » Tue 15 Apr 2014 10:41

Thank you for your report. We have reproduced the issue and are working on it.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44

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

Postby Shalex » Thu 24 Apr 2014 14:41

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.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44

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

Postby Dennis Wanke » Thu 24 Apr 2014 16:59

I confirm the behavior is now consistent.
Dennis Wanke
 
Posts: 57
Joined: Tue 11 Mar 2014 07:49


Return to dotConnect for Oracle