5 Replies Latest reply: Oct 15, 2013 7:24 AM by Martin 12345 RSS

    How to switch my project from using Unmanaged to Managed ODP.NET?

    OTNetUser

      Long story short, my server has ODP.NET 2.112.1.2 which does not support Entity Framework currently being used by my ASP.NET application running with ODP.NET 2.112.3.0. The server admin would not upgrade ODP.NET because it is a shared host.

      I'm trying to switch to managed ODP.NET. Here is what I did.

      +Installed Managed ODP.NET from NuGet. +Verified Oracle.ManagedDataAccess.dll is in the reference +Change the web config from

      <connectionStrings> <add name="MYEntities" connectionString="metadata=res://*/App_Code.MYModel.csdl|res://*/App_Code.MYModel.ssdl|res://*/App_Code.MYModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=xxxxxx.com;PASSWORD=xxxxx;USER ID=xxxxx&quot;" providerName="System.Data.EntityClient"/>

       

      to:

      <connectionStrings> <add name="MYEntities" connectionString="metadata=res://*/App_Code.MYModel.csdl|res://*/App_Code.MYModel.ssdl|res://*/App_Code.MYModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=xxxxxx.com;PASSWORD=xxxxx;USER ID=xxxxx&quot;" providerName="System.Data.EntityClient"/>

       

      +Changed the .edmx file from:

      <Schema Namespace="BOTModel.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">

      to:

      <Schema Namespace="BOTModel.Store" Alias="Self" Provider="Oracle.ManagedDataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">

      When I run the application on my localhost. I get this error:

      Unable to find the requested .Net Framework Data Provider.  It may not be installed.  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.  Stack Trace:   [ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.] System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1426271 System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +27  [ArgumentException: The specified store provider cannot be found in the configuration, or is not valid.] System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +92 System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +246 System.Data.EntityClient.EntityConnection..ctor(String connectionString) +43 System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) +78 System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +32 System.Data.Entity.Internal.LazyInternalConnection.Initialize() +127 System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() +13 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +274 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +52 System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15 System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37 System.Linq.Queryable.Join(IQueryable`1 outer, IEnumerable`1 inner, Expression`1 outerKeySelector, Expression`1 innerKeySelector, Expression`1 resultSelector) +96 Competency_Competency.fillPage() in c:\websites\Trustees4.0\BOT\ipad\Competency\Competency.aspx.cs:24 Competency_Competency.Page_Load(Object sender, EventArgs e) in c:\websites\Trustees4.0\BOT\ipad\Competency\Competency.aspx.cs:15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +92 System.Web.UI.Control.LoadRecursive() +54 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772  Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
        • 1. Re: How to switch my project from using Unmanaged to Managed ODP.NET?
          Alex.Keh .Product.Manager-Oracle

          It appears you're missing the <ProviderFactories> section for ODP.NET in the machine.config.

           

          If you cannot run a GUI installer on the target machine, you can run the install batch script from the managed ODP.NET xcopy install. I would recommend running the entire script or at least understanding what each line of the script is doing. As long as you understand what each command does, you can decide whether or not you need it and avoid common install errors.

          • 2. Re: How to switch my project from using Unmanaged to Managed ODP.NET?
            Mark Williams-Oracle

            Hi,

             

            Further to what Alex has already mentioned, I notice you say:

             

            "Installed Managed ODP.NET from NuGet"

             

            I would just like to point out that Oracle does not distribute ODAC components via NuGet, so what you've picked up is likely not an official Oracle distribution. As such, it's hard to say what the package you've acquired does or does not do.

             

            Also, I suspect posting ODAC components on NuGet is a violation of the license agreement used to acquire the package. For example, from the OTN license agreement for ODAC download I see this:

            ...

            You may not:

            [snip]

            - distribute the programs unless accompanied with your applications;

            ...

             

            The official Oracle distributions of the components can be found here:

             

            http://www.oracle.com/technetwork/database/windows/downloads/index.html

             

            Using an official distribution of the components should allow you to successfully follow Alex's tips for a correct install.

             

            Regards,

            Mark

            • 3. Re: How to switch my project from using Unmanaged to Managed ODP.NET?
              OTNetUser

              Thank you all for the replies.

               

              I cannot run the bat script to add the setting in the machine.config file on the server so that route won't work.

               

              I'm currently running on Oracle 11g. I don't find any ODAC with managed ODP.NET for oracle 11g db, only for 12c.

              ODAC 12c Release 1 (12.1.0.1.0)

               

              I downloaded xcopy of ODAC 12c Release 1 (12.1.0.1.0) and followed the installation instruction on this thread.


              oracle - Deploying and Configuring ODP.NET to work without installation with Entity Framework - Stack Overflow


              After that I got this error:


              ORA-12154: TNS:could not resolve the connect identifier specified

               

               

              Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

               

               

              Exception Details: OracleInternal.Network.NetworkException: ORA-12154: TNS:could not resolve the connect identifier specified

               

              Stack Trace:

               

               

               

               

              [NetworkException (0x2f7a): ORA-12154: TNS:could not resolve the connect identifier specified]

                 OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName) +548

                 OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor) +68

                 OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, String instanceName) +3287

               

               

              [OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified]

                 OracleInternal.ConnectionPool.PoolManager`3.CreateNewPR(Int32 reqCount, Boolean bForPoolPopulation, ConnectionString csWithDiffOrNewPwd, String instanceName) +1441

                 OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +3185

                 OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +691

                 OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword) +800

                 Oracle.ManagedDataAccess.Client.OracleConnection.Open() +2092

                 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +44

               

               

              [EntityException: The underlying provider failed on Open.]

                 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +203

                 System.Data.EntityClient.EntityConnection.Open() +104

                 System.Data.Objects.ObjectContext.EnsureConnection() +75

                 System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +41

                 System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +36

                 System.Data.Entity.Internal.Linq.InternalQuery`1.GetEnumerator() +72

                 System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +40

                 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +369

                 System.Linq.Enumerable.ToList(IEnumerable`1 source) +58

                 Competency_Competency.fillPage() in c:\websites\Trustees4.0\BOT\ipad\Competency\Competency.aspx.cs:24

                 Competency_Competency.Page_Load(Object sender, EventArgs e) in c:\websites\Trustees4.0\BOT\ipad\Competency\Competency.aspx.cs:15

                 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51

                 System.Web.UI.Control.OnLoad(EventArgs e) +92

                 System.Web.UI.Control.LoadRecursive() +54

                 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

               

               

              Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044

              • 4. Re: How to switch my project from using Unmanaged to Managed ODP.NET?
                Alex.Keh .Product.Manager-Oracle

                The Oracle net service name you used couldn't resolve the DB connect descriptor. Check your tnsnames.ora file to make sure you are referencing the correct net service name and that your connect descriptor is properly set up.

                • 5. Re: How to switch my project from using Unmanaged to Managed ODP.NET?
                  Martin 12345

                  Hi,

                  here a list of things that I did when not being able to make big changes to the system where to deploy the managed code (12c client here):

                   

                  web.config add to configSections

                  <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

                  web.config add to configuration

                  <oracle.manageddataaccess.client>

                      <version number="*">

                        <settings>

                          <setting name="TNS_ADMIN" value="PATH TO YOUR TNS FOLDER (containing the tnsnames.ora)"/>

                        </settings>

                      </version>

                    </oracle.manageddataaccess.client>

                    <system.data>

                      <DbProviderFactories>

                        <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.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

                      </DbProviderFactories>

                    </system.data>

                  in the web.config change the connectionstrings part to the ManagedDataAccess Provider and eventually adapt the connection string (when coming from System.Data.OracleClient)

                  Probably you need to adapt the EF connection string.

                   

                  With address resolution I ran into a problem when setting up new and forgetting that the SQLNET.ora contained a default domain (which was missing when I forgot, for use with tnsnames.ora).

                  Best

                  Martin