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
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:
app.configfile, but there is
Web.configfile (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".)
<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>
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
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:
<configSections> <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=188.8.131.52, Culture=neutral, PublicKeyToken=89b483f429c47342" /> </configSections>
<dependentAssembly> <publisherPolicy apply="no" /> <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" /> <bindingRedirect oldVersion="184.108.40.206 - 4.65535.65535.65535" newVersion="220.127.116.11" /> </dependentAssembly>
Oracle.ManagedDataAccess version 18.104.22.168)
Entity Framework provider
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=22.214.171.124, Culture=neutral, PublicKeyToken=89b483f429c47342" />
All in the