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

entity-framework-6 odp.net oracle


I am having a hard time working with EF and Oracle. Earlier, I have developed an app that use EF and Oracle and have ran well. I installed the ODAC in local computer (GAC) that contains Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework.

This time I develop an app that using EF and Oracle too, but I just want to use the NuGet package of Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework.

this is my app.config

    <section name="entityFramework"
      type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    <section name="oracle.manageddataaccess.client"
      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
      <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=, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
      <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=, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <publisherPolicy apply="no"/>
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
        <bindingRedirect oldVersion=" - 4.65535.65535.65535" newVersion=""/>
    <version number="*">
        <dataSource alias="myDataSource" descriptor="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = host)(PORT = port))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))"/>
    <add name="myConnectionString" providerName="Oracle.ManagedDataAccess.Client"
      connectionString="User Id=user_id;Password=password;Data Source=myDataSource"/>

I tried to run a simple query:

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

And it throws exception:

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

Then using this post I add this to my code:

protected override void OnModelCreating(DbModelBuilder modelBuilder)

Well, it run well in my development environment. And when I try to run it in the server, which didn't have ODAC installed, it throws this exception.

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

Well, it's pretty weird, and I am really confused. Please help.

4/30/2018 4:44:10 AM

Popular Answer

The Problem: You are trying to create tables into the database that it already exists from the previous migration.

The Solution: Delete every thing from the database first and then make your migrations.

There is an oracle query that helps you to make that it's in this link How to drop all user tables?

7/18/2018 12:15:06 PM

Related Questions


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