Oracle.ManagedDataAccess.EntityFramework – ORA-01918: l’utente ‘dbo’ non esiste

Sto cercando di implemente il codice First Migrations con Oracle.ManagedDataAccess 6.121.1.0 provider, ma senza alcun risultato.

Poiché sto ricevendo un codice ORA, presumo che la connessione sia stata aperta con successo. Ma le migrazioni stanno fallendo perché, forse, il provider si comporta come un server SQL, anziché Oracle. Penso che si stia tentando di usare “dbo” come schema predefinito.

Ecco le mie impostazioni web.config:

  

Qui lo Stacktrace:

[OracleException (0x77e): ORA-01918: l’utente ‘dbo’ non esiste]
OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution (OracleConnectionImpl connectionImpl, Int32 & cursorId, bThrowArrayBindRelatedErrors booleani, OracleException & exceptionForArrayBindDML, booleano e hasMoreRowsInDB, booleano bFirstIterationDone) 652 OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution (OracleConnectionImpl connectionImpl, Int32 & cursorId, bThrowArrayBindRelatedErrors booleani, OracleException & exceptionForArrayBindDML, booleano bFirstIterationDone ) +39
OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery (String commandText, OracleParameterCollection paramColl, CommandType CommandType, OracleConnectionImpl connectionImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64 [] & scnFromExecution, OracleParameterCollection & bindByPositionParamColl, booleano e bBindParamPresent, OracleException & exceptionForArrayBindDML, booleano isFromEF) 7480
Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery () +678
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.b__0 (DbCommand t, DbCommandInterceptionContext 1 c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1 c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1 c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch (target TTarget, 3 operation, TInterceptionContext interceptionContext, Action Func 3 operation, TInterceptionContext interceptionContext, Action 3 in esecuzione, Action 3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +357
System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery() +104
System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement, DbInterceptionContext interceptionContext) +152
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable
3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +357
System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery() +104
System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement, DbInterceptionContext interceptionContext) +152
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable
3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +357
System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery() +104
System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement, DbInterceptionContext interceptionContext) +152
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable
1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext) +82
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal (IEnumerable 1 migrationStatements, DbConnection connection) +626
System.Data.Entity.Migrations.c__DisplayClass30.b__2e() +19
System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Action operation) +9
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable
1 migrationStatements, DbConnection connection) +626
System.Data.Entity.Migrations.c__DisplayClass30.b__2e() +19
System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Action operation) +9
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable
1 migrationStatements, DbConnection connection) +626
System.Data.Entity.Migrations.c__DisplayClass30.b__2e() +19
System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Action operation) +9
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable
1 migrationStatements, DbTransaction existingTransaction) +194
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements (IEnumerumer 1 migrationStatements) +7
System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable
1 migrationStatements) +7
System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable
1 migrationStatements) +7
System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable
1 operazioni, IEnumerable 1 systemOperations, Boolean downgrading, Boolean auto) +825
System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading) +564
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable
1 systemOperations, Boolean downgrading, Boolean auto) +825
System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading) +564
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable
1 systemOperations, Boolean downgrading, Boolean auto) +825
System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading) +564
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable
1 pendingMigrations, String targetMigrationId, String lastMigrationId) +404
System.Data.Entity.Migrations.DbMigrator.UpdateInternal (String targetMigration) +447
System.Data.Entity.Migrations. C__DisplayClassc.b__b () +13
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists (Action mustSucceedToKeepDatabase) +422
System.Data.Entity.Migrations.DbMigrator.Update (String targetMigration) +78
System.Data.Entity.Internal.DatabaseCreator.CreateDatabase (InternalContext internalContext, Func 3 createMigrator, ObjectContext objectContext) +89
System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
System.Data.Entity.DropCreateDatabaseAlways
3 createMigrator, ObjectContext objectContext) +89
System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
System.Data.Entity.DropCreateDatabaseAlways
3 createMigrator, ObjectContext objectContext) +89
System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
System.Data.Entity.DropCreateDatabaseAlways
1.InitializeDatabase (contesto TContext) +137

Ho avuto lo stesso problema ed è stato risolto dalla risposta di Thiago Lunardi. Grazie. Non avevo abbastanza reputazione per votare la tua risposta. Per citare qui, sono riuscito dopo aver impostato il nome dello schema in MAIUSCOLO.

Metti questo nel tuo file di contesto sotto la tua nuova class dbContext, in questo modo:

 public partial class MyAppContext : DbContext protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema("UPPERCASE_SCHEMA_NAME"); ... 

Risolvo questo semplicemente impostando lo schema predefinito su modelBuilder

 protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema("MyOracleSchema"); // ... } 

L’impostazione dello schema predefinito non ha funzionato per me. Ho trovato la soluzione personalizzando la tabella della cronologia delle migrazioni per impostare uno schema diverso.

Puoi trovare una soluzione qui: LINK .

L’utente Dbo arriva anche nel caso in cui manchi il nome completo della tabella. Quale non può mappare alla tabella giusta nel database.

inserisci la descrizione dell'immagine qui

Se si utilizza Migrazioni automatiche (come ero), si noti: modelBuilder.HasDefaultSchema può essere d’aiuto finché non si passa a migrazioni esplicite.

Da Oracle Docs :

Code First Automatic Migrations è limitato a funzionare solo con lo schema dbo . A causa di questa limitazione, si consiglia di utilizzare migrazioni basate su codice, ovvero aggiungere migrazioni esplicite tramite il comando Add-Migration

in Code First è ansible utilizzare le informazioni DataAnnotations per Table.

[Tabella (“Emplpoyee”, Schema = “IL TUO NOME SCHEMA”]