Page 1 of 1

Migrations in multiples context (ORA-00955)

Posted: Tue 21 Aug 2018 14:15
by josue.agnese
Hi!

Current Devart Versions:
- Devart.Data.Oracle.EFCore (9.6.570)
- Devart.Data.Oracle (9.6.570)

I my application, I have 4 DbContexts for the same database.

When I run migrations to the first DbContext no problem occurs.
When executing the migrations to the second DbContext it tries to recreate the table of migrations, but it already exists in the database

Code: Select all

Update-Database -Context:OracleRacDbContext -v
Migrating using database '' on server '127.0.0.1/DBO'.
Opening connection to database '' on server '127.0.0.1/DBO'.
Opened connection to database '' on server '127.0.0.1/DBO'.
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='0']
SELECT COUNT(*)
  FROM SYS.ALL_TABLES
 WHERE (OWNER = SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') AND TABLE_NAME IN ('TNFCLIENTCUSTOMIZATIONS', 'TNFFEATURES', 'TNFORGANIZATIONTREETABLE', 'TNFORGANIZATIONUNITS', 'TNFPERMISSIONS', 'TNFPRODUCTS', 'TNFROLES', 'TNFROLECLAIMS', 'TNFTENANTS', 'TNFTENANTPRODUCTS', 'TNFUSERS', 'TNFUSERACCOUNTS', 'TNFUSERCLAIMS', 'TNFUSERLOGINS', 'TNFUSERLOGINATTEMPTS', 'TNFUSERORGANIZATIONUNITS', 'TNFUSERROLES', 'TNFUSERTOKENS'))
Executed DbCommand (103ms) [Parameters=[], CommandType='Text', CommandTimeout='0']
SELECT COUNT(*)
  FROM SYS.ALL_TABLES
 WHERE (OWNER = SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') AND TABLE_NAME IN ('TNFCLIENTCUSTOMIZATIONS', 'TNFFEATURES', 'TNFORGANIZATIONTREETABLE', 'TNFORGANIZATIONUNITS', 'TNFPERMISSIONS', 'TNFPRODUCTS', 'TNFROLES', 'TNFROLECLAIMS', 'TNFTENANTS', 'TNFTENANTPRODUCTS', 'TNFUSERS', 'TNFUSERACCOUNTS', 'TNFUSERCLAIMS', 'TNFUSERLOGINS', 'TNFUSERLOGINATTEMPTS', 'TNFUSERORGANIZATIONUNITS', 'TNFUSERROLES', 'TNFUSERTOKENS'))
Closing connection to database '' on server '127.0.0.1/DBO'.
Closed connection to database '' on server '127.0.0.1/DBO'.
DetectChanges starting for 'OracleRacDbContext'.
DetectChanges completed for 'OracleRacDbContext'.
Opening connection to database '' on server '127.0.0.1/DBO'.
Opened connection to database '' on server '127.0.0.1/DBO'.
Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='0']
CREATE TABLE EFMigrationsHistory__ ( 
  MigrationId NVARCHAR2(150) NOT NULL,
  ProductVersion NVARCHAR2(32) NOT NULL,
  PRIMARY KEY (MigrationId)
)
Failed executing DbCommand (8ms) [Parameters=[], CommandType='Text', CommandTimeout='0']
CREATE TABLE EFMigrationsHistory__ ( 
  MigrationId NVARCHAR2(150) NOT NULL,
  ProductVersion NVARCHAR2(32) NOT NULL,
  PRIMARY KEY (MigrationId)
)
Closing connection to database '' on server '127.0.0.1/DBO'.
Closed connection to database '' on server '127.0.0.1/DBO'.
'OracleRacDbContext' disposed.
Devart.Data.Oracle.OracleException (0x80004005): ORA-00955: name is already used by an existing object
   at   .      ()
   at   .()
   at   .      ()
   at   .(   , Int32 )
   at   .      (Int32 ,    )
   at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()
   at   .ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ORA-00955: name is already used by an existing object

Re: Migrations in multiples context (ORA-00955)

Posted: Mon 27 Aug 2018 18:49
by Shalex
We will investigate the issue and notify you about the result.

Re: Migrations in multiples context (ORA-00955)

Posted: Tue 28 Aug 2018 14:10
by Shalex
We have reproduced the problem and are investigating it. We will notify you when the issue is fixed.

Re: Migrations in multiples context (ORA-00955)

Posted: Thu 20 Sep 2018 15:11
by Shalex
The bug with creating database objects in the same schema by several EF Core contexts in Code-First approach is fixed: viewtopic.php?f=1&t=37715.