Oracle.ManagedDataAccess - Steps to get it working

Posts   
 
    
gummidrum
User
Posts: 11
Joined: 13-Dec-2013
# Posted on: 29-Jan-2014 18:38:35   

What do I need to do to have my generated code use Oracle.ManagedDataAccess?

I am using LLBLGen pro 4.1. Relational Model Data uses Oracle (ODP.NET) I am using the Adapter template group.

I have been trying to follow the steps indicated in this thread:

http://llblgen.com/tinyforum/Messages.aspx?ThreadID=22160

But I can't seem to get it work. I have the same version of Oracle.ManagedDataAccess.dll (4.121.1.0) as described in the thread. My understanding is that what is needed is this:

  1. The Oracle.ManagedDataAccess.dll should exist in the same directory as the code is executed from.
  2. TnsName.ora should also be in this folder.
  3. I added this to my config file as this thread indicades:

<system.data>

<DbProviderFactories>
 <!--Remove in case this is already defined in machine.config-->
 <remove invariant="Oracle.DataAccess.Client" />
 <add name="Oracle Data Provider for .NET"
     invariant="Oracle.DataAccess.Client"
     description="Oracle Data Provider for .NET, Managed Driver"
     type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
Walaa avatar
Walaa
Support Team
Posts: 14952
Joined: 21-Aug-2005
# Posted on: 29-Jan-2014 21:42:25   

But I can't seem to get it work.

Could you please explain in details how you found it not working?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39620
Joined: 17-Aug-2003
# Posted on: 30-Jan-2014 11:45:43   

The version specified in the factory definition should be the version of your managed oracle dll. Also make sure you're using .net 4 or higher.

If in doubt, install the odp.net for 12c from otn.

Frans Bouma | Lead developer LLBLGen Pro
gummidrum
User
Posts: 11
Joined: 13-Dec-2013
# Posted on: 30-Jan-2014 17:05:48   

I was missing some elements in my config files that I found on this usefull blog:

http://blog.vijay.name/2012/11/oracle-managed-odp-net/

I am now getting this error:

OracleConnection.ConnectionString is invalid

at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.OpenConnection()
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List`1 valueProjectors, IGeneralDataProjector projector, IRetrievalQuery queryToExecute, Dictionary`2 typeConvertersToRun)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List`1 valueProjectors, IGeneralDataProjector projector, QueryParameters parameters)
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteValueListProjection(QueryExpression toExecute)
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
   at Saga.BusinessLogic.Server.DBSettings.AllowedVersion() in c:\git\Saga\SAGA.NET\Layers\Business Logic\Saga.BusinessLogic\Server\DBSettings.cs:line 35
   at Saga.Presentation.ClientIntegration.Common.CommonService.VerifyServiceSetup(String dbSchemaName, String clientVersion) in c:\git\Saga\SAGA.NET\Layers\Presentation\Saga.Presentation.ClientIntegration\Common\CommonService.svc.cs:line 38

This is what I have in my config:


<?xml version="1.0"?>
<configuration>
   <configSections>
...
...
...
<add key="Main.ConnectionString" value="data source=bleh;user id=bleh;password=bleh;persist security info=false;"/>
      <add key="SchemaNameUsageSetting" value="1"/>
      <add key="SchemaNameToUse" value="BLEH"/>
      <add key="OracleAnsiJoins" value="true"/>
      <add key="OracleDQECompatibilityLevel" value="0" />
...
...
...
<system.data>
      <DbProviderFactories>
         <!--Remove in case this is already defined in machine.config-->
         <remove invariant="Oracle.DataAccess.Client" />
         <add name="Oracle Data Provider for .NET"
             invariant="Oracle.DataAccess.Client"
             description="Oracle Data Provider for .NET, Managed Driver"
             type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      </DbProviderFactories>
   </system.data>
   <oracle.manageddataaccess.client>
      <version number="*">
         <settings>
            <!-- Set this path if you are using TNS aliases as connection strings (not recommended) -->
            <!-- Instead you can use "SERVER_NAME:PORT/SERVICE_NAME" as your data source -->
            <setting name="TNS_ADMIN" value="C:\Oracle\product\11.2.0\client_1\network\admin" />
         </settings>
         <dataSources>
            <dataSource alias="bleh.b.is" descriptor="(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SID = orcl) ) )"/>
         </dataSources>
         <edmMappings>
            <edmMapping dataType="number">
               <add name="bool" precision="1"/>
               <add name="byte" precision="2" />
               <add name="int16" precision="5" />
            </edmMapping>
         </edmMappings>
      </version>
   </oracle.manageddataaccess.client>
</configuration>
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39620
Joined: 17-Aug-2003
# Posted on: 31-Jan-2014 11:06:03   

I don't know why you have that <oracle.manageddataaccess.client> section in your config file. That's not needed. Here in testing we simply use the same connection string as with normal ODP.NET and no <oracle.manageddataaccess.client> section needed. The datasource specified in the connection string has to be a valid oracle reference, so either a tns name, or a server specification with port.

Either way, the connection string passed to connection.Open is not in the right format according to the oracle ado.net provider (so the error originates from the oracle code).

Frans Bouma | Lead developer LLBLGen Pro