ORA-00955: name is already used by an existing object; When using Oracle.ManagedDataAccess and EntityFramework

entity-framework-6 odp.net oracle

Question

Working with EF and Oracle is challenging for me. In the past, I created an app that successfully used Oracle and EF. On my own computer (GAC), which has Oracle, I installed ODAC. Oracle as well as ManagedDataAccess. ManagedDataAccess.EntityFramework.

This time, I'm developing an app that also uses Oracle and EF, but I just want to utilise the Oracle NuGet package. Oracle as well as ManagedDataAccess. ManagedDataAccess.EntityFramework.

My app.config is shown below.

<configuration>
  <configSections>
    <section name="entityFramework"
      type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      requirePermission="false"/>
    <section name="oracle.manageddataaccess.client"
      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
      <provider invariantName="Oracle.ManagedDataAccess.Client"
        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client"/>
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
        type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <publisherPolicy apply="no"/>
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
        <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="myDataSource" descriptor="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = host)(PORT = port))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))"/>
      </dataSources>
    </version>
  </oracle.manageddataaccess.client>
  <connectionStrings>
    <add name="myConnectionString" providerName="Oracle.ManagedDataAccess.Client"
      connectionString="User Id=user_id;Password=password;Data Source=myDataSource"/>
  </connectionStrings>
</configuration>

I tried using a straightforward query:

pulic IEnumerable<int> GetIDs()
{
    var context = new MyDbContext();
    var sql = "SELECT ID FROM SOME_TABLE";
    return context.Database.SqlQuery<Payable>(sql.ToString());
}

It also raises an exception:

Oracle.ManagedDataAccess.Client.OracleException: ORA-01918: user 'dbo' does not exist

Using these words, I then add the following to my code:

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

It performed well in my development environment. And it gives this problem when I attempt to execute it on the server, which didn't have ODAC installed.

Oracle.ManagedDataAccess.Client.OracleException: ORA-00955: name is already used by an existing object

Well, it's kind of strange, and I'm extremely perplexed. Thank you.

1
0
4/30/2018 4:44:10 AM

Popular Answer

ZZZ_tmp
1
7/18/2018 12:15:06 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow