locked
ORA-00604 & ORA-08177 with entity framework RRS feed

  • Question

  • User-875744750 posted

    hello all

    i'm beginner in asp.net mvc and entity framework. and i have started following this example in github : https://github.com/abdelkafiahmed/BankManagementSystem

    i creatd a new project MVC5 in visual studio 2012 ultimate, all model class (Banque, Client,...etc), and entity framework context class BankDbContext.

    i have oracle database 12c version

    Since there is not a connection string in web.config on this example, i decided to use entity framework for accessing to oracle database. i downloaded by nuget and installed the oracle.ManagedDataAccess.EntityFramework, oracle.ManagedDataAccess and EntityFramework v6 packages and t alrered the connection string given by thes packages to

    <oracle.manageddataaccess.client>
        <version number="*">
          <dataSources>
            <dataSource alias="ORCL" descriptor="(DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
        (CONNECT_DATA =
          (SERVICE_NAME = orcl) 
        )
      )" />
          </dataSources>
        </version>
    </oracle.manageddataaccess.client>
    <connectionStrings>
        <add name="BankDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=bcdratest;Password=bcdratest;Data Source=ORCL" />
    </connectionStrings>

    after i have created the Initializer class:

    namespace BankAccountsManagementSystem.DataAccessLayer
    {
        public class Initializer :DropCreateDatabaseAlways<BankDbContext>
        {
            protected override void Seed(BankDbContext context)
            {
    
    
                using(var ctx = new BankDbContext())
                {
                   var  banque = new Banque
                   {
                       Nom="ENIT Bank",
                       ArgentDepose = 0.0m,
                       Capital =0.0m,
                       NbreClients = 0,
                       NbreComptes=0,
                       NbreCredits=0,
                       SommeCredits = 0
                    };
    
                    ctx.Banques.Add(banque);
                    ctx.SaveChanges();
                  }             
                }
    
    
            }
        }

    i have started by creating a BanquesController and Banques/Index view when i executed the application, the database is created in first time. after, i created PersonneMoralesController by scaffolding and altered the index Action by the code on this example

    here

    but when executing the application i get an exception:

    ORA-00604: error occurred at recursive SQL level string 1
    
    ORA-08177: can't serialize access for this transaction

     and database is not recreated.

    i thought that i have got these errors because of the codes in initializer and banque Controller Index Action, two transactions in same Banques table, so i excluded this Initializer Class File.

    but even this, the problem persists when the exectioning of application

    why and how to fix this?

    soon

    Monday, January 29, 2018 9:26 PM

Answers

  • User269602965 posted
    Try this web config  arrangement.  That way you avoid tnsnames.ora errors on typing.
    
      <configSections>
        <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess"/>
      </configSections>
      <connectionStrings>
      -- you connection string here
      </connectionStrings>
      <oracle.manageddataaccess.client>
        <version number="*">
          <settings>
            <setting name="tns_admin" value="{the drive and path to your tnsnames.ora file}" />
          </settings>
        </version>
      </oracle.manageddataaccess.client>
      <system.data>
        <DbProviderFactories>
          <remove invariant="Oracle.DataAccess.Client" />
          <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>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 29, 2018 9:59 PM
  • User-875744750 posted

    hello and thank you

    i resolved that issue by: verify your DataSource in Web.Config. it contain the alias and description of TNS that it should be the same in tnsname.ora of  ODP.NET that is Installed in my machine.

    verify if Oracle.ManagedDataAccess(.EntityFramework) package version is compatible with ODP.Net in my machine. my ODP.NET version is 12.1.024. so, the Oracle.ManagedDataAccess(.EntityFramework) package have to be 12.1.024. and less than 12.2.0

    soon

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 18, 2018 8:53 PM

All replies

  • User269602965 posted
    Try this web config  arrangement.  That way you avoid tnsnames.ora errors on typing.
    
      <configSections>
        <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess"/>
      </configSections>
      <connectionStrings>
      -- you connection string here
      </connectionStrings>
      <oracle.manageddataaccess.client>
        <version number="*">
          <settings>
            <setting name="tns_admin" value="{the drive and path to your tnsnames.ora file}" />
          </settings>
        </version>
      </oracle.manageddataaccess.client>
      <system.data>
        <DbProviderFactories>
          <remove invariant="Oracle.DataAccess.Client" />
          <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>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 29, 2018 9:59 PM
  • User-875744750 posted

    thank you for replay

    i tried this :

    <settings>
    <setting name="tns_admin" value="G:\app\client\bensam\product\12.1.0\client_1\Network\Admin\tnsnames"/>
    </settings>

    but the probleme persists

    Monday, January 29, 2018 10:32 PM
  • User269602965 posted

    I put my managed Oracle driver DLL(s) AND tnsnames.ora in the /BIN folder of the application.

    I make local reference to the Oracle driver DLLs.

    Then you do not have to make permissions on the Oracle installation Client Network admin folder .

    Then remove the tns settings name as the Managed Driver will automatically look in the app /BIN folder.

    Tuesday, January 30, 2018 12:13 AM
  • User269602965 posted

    Also when I start my app (ASP, WPF, WinForm, Console), I first TEST the connection with OPEN and CLOSE to test the client is working, reporting problem to you the admin and the user.. sorry we cannot connect to database.

    Tuesday, January 30, 2018 12:15 AM
  • User269602965 posted

    The other little thing you should know about the Oracle MANAGED DRIVER version 12cR4 and earlier.

    If your database is Oracle 11g or Oracle 10g AND your servers have Local or Group SECURITY POLICY of FIPS ENABLED, the Managed Driver will FAIL to connect.

    If your security policy requires FIPS ENABLED, you will have to use the ORACLE UNMANAGED DRIVER.

    They have reportedly fixed this problem on the database side in Oracle 12c, but I have not yet tested that.

    Wednesday, January 31, 2018 3:35 PM
  • User-875744750 posted

    hello and thank you

    i resolved that issue by: verify your DataSource in Web.Config. it contain the alias and description of TNS that it should be the same in tnsname.ora of  ODP.NET that is Installed in my machine.

    verify if Oracle.ManagedDataAccess(.EntityFramework) package version is compatible with ODP.Net in my machine. my ODP.NET version is 12.1.024. so, the Oracle.ManagedDataAccess(.EntityFramework) package have to be 12.1.024. and less than 12.2.0

    soon

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 18, 2018 8:53 PM