.net oracle connection

.net oracle connection

montoyammontoyam Posts: 149Questions: 38Answers: 3

I am trying to connect to an oracle database in my .net project. I am getting an error in the line

using (var db = new Database(settings.DbType, settings.DbConnection))

error is: unable to find the requested .net framework data provider. it may not be installed

do I need add a reference to something?

Answers

  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    This is .NET core I guess? Unlike .NET Framework (which usual a global machine configuration) you need to tell .NET Core to register database handlers. There is some information about that in our documentation here.

    Allan

  • montoyammontoyam Posts: 149Questions: 38Answers: 3

    no, I am using .NET framework. Do I need to use .NET core?

  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    Oh - if you are using .NET Framework I would have expected it to just work. Assuming you have the Oracle .NET driver installed on your system? What version of it are you using?

    Allan

  • montoyammontoyam Posts: 149Questions: 38Answers: 3

    I was trying to use Oracle.DataAccess but had issues with the project not loading. Then I switched to Oracle.ManagedDataAccess.dll. but still getting that error above.

  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    Yes, the ManagedDataAccess client is the one we use by default.

    What version of that library have you got referenced in the project?

    Thanks,
    Allan

  • montoyammontoyam Posts: 149Questions: 38Answers: 3

    4.122.1.0

    I tried Oracle.DataAccess.EntityFramework 6.122.1.0 as well with no luck.

  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    Yes, the EF module won't help unfortunately.

    Could you show me your machine.config file contents please? This SO question might help with that.

    Allan

  • montoyammontoyam Posts: 149Questions: 38Answers: 3

    in one of my machine.config files I see this:

        <system.data>
            <DbProviderFactories>
               <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
               <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
               <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
               <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
            </DbProviderFactories>
        </system.data>
    
  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    One of them? Are you sure that it is that one which is being loaded? Or is it possible another is being loaded which does not include the Oracle client reference?

    Allan

  • montoyammontoyam Posts: 149Questions: 38Answers: 3

    when I make changes to this one I get errors when the datatables tries to load, so it definitely is using this one. However, I did read somewhere that all of them may be loaded.

    But does the machine.config I posted above look correct?

  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    It does look fine like that.

    Could you show me the connection string you are using for the database please? (obfuscate the username and password of course :)).

    I'm not sure this is the answer, but this thread says you might need to add some configuration to the web.config file - but I'm not convinced by that one since we've not had to do that. The connection string is the next port of call I think.

    Allan

  • allanallan Posts: 51,440Questions: 1Answers: 7,758 Site admin

    There is another thread here which might be of interest.

    So if it of any consolation - you aren't the only one having problems with the Oracle drivers on .NET.

    How are you normally making a connection to your Oracle db?

    Regards,
    Allan

Sign In or Register to comment.