How to Add/Activate "Oracle.ManagedDataAccess.Client" in the EF 6 provider config file?

asp.net-mvc c# entity-framework odp.net oracle-manageddataaccess

Question

I am learning to make ASP.Net MVC Web application using VS2013 following these video series. When I got the following error:

No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.ManagedDataAccess.Client'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

(In the video, the database provider used is the natural System.Data.SqlClient for ASP.Net application, but I need to use Oracle.ManagedDataAccess.Client)

The error itself is not new in SO. And, as suggested by the error message and by the accepted answer of the SO question, I checked if the ODP.Net provider is supported by EF 6.0 and I found that it is. Nevertheless I still cannot make it work.

I am pretty new to MVC and so I seek your understanding if there be any concepts of MVC application/settings which I understand wrongly at this point and I am open to your corrections.

Some additional info which might be useful:

  • I use ASP.Net Web Application template provided by my VS2013 to start the project. I use MVC template for it and only "Add folders and core references for" MVC. I neither "Add unit tests" not "Host in the cloud"
  • In the template, there isn't app.config file, but there is Web.config file (does this make any difference? It is suggested in the error message to "Make sure the provider is registered in the 'entityFramework' section of the application config file".)
  • In the Web.config file, I found the following entityFramework portion:
    <entityFramework>
      <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameters>
          <parameter value="mssqllocaldb" />
        </parameters>
      </defaultConnectionFactory>
      <providers>
        <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      </providers>
    </entityFramework>
  • I notice that there is

    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />` 
    

    line there. And thus I try to similarly add:

    <provider invariantName="Oracle.ManagedDataAccess.Client" type=???, EntityFramework.???" />
    

    But I do not know what to write for the type attribute and the EntityFramework.??? and has been stuck for a couple of hours. And if I do not put it, I got the following warning:

    The required attribute "type" is missing

    Any help for this will be appreciated.

I also am open if you know that there is any additional things which I need to do besides adding the provider to fix this issue. My connections strings in the web.config file are as follow:

<connectionStrings>
  <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcWebApplication1-20160212010850.mdf;Initial Catalog=aspnet-MvcWebApplication1-20160212010850;Integrated Security=True"
    providerName="System.Data.SqlClient" />
   <add name="EmployeeContext" connectionString="Data source=aaaaa;user id=bbbbbb;password=cccccc;persist security info=True"   providerName="Oracle.ManagedDataAccess.Client"/>
</connectionStrings>
1
3
10/15/2019 7:36:38 PM

Accepted Answer

I got the answer from an Oracle's ODP.Net document and an Oracle Community forum:

Apperantly, according to the accepted answer, until early 2014, the EF 6 is not supported by ODAC as stated in its document. One must partially use EF 5 to work with Oracle.ManagedDataAccess

When I checked the document that the accepted answer refers to, however, I did not find the statement which suggested what the answerer wrote - leading me to believe that as of now, Oracle.ManagedDataAccess could have been supported in EF 6.

And then I found this document which contains quite a number of tricks to solve possible issues when using Oracle.ManagedDataAccess in EF 6.

The one which particularly works for me is by adding:

  1. Config Sections
    <configSections>
      <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </configSections>
  1. Dependent Assembly

    <dependentAssembly>
      <publisherPolicy apply="no" />
      <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
      <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0" />
    </dependentAssembly>
    

    (I used Oracle.ManagedDataAccess version 4.121.2.0)

  2. Entity Framework provider

    <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    

All in the Web.config file

0
10/15/2019 7:33:47 PM


Related Questions





Related

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