Search code examples
oracleodatadevart

'The ADO.NET provider with invariant name 'Devart.Data.Oracle' is either not registered in the machine or application config file


Ok, there already is a similar issue. It is, however not exactly the same and the solution I got was not derived from the other issue's solution.

Here's my Web.Config setup:

<connectionStrings>
  <add name="ADOEntities" connectionString="metadata=res://*/ADOModel.csdl|res://*/ADOModel.ssdl|res://*/ADOModel.msl;provider=Devart.Data.Oracle;provider connection string=&quot;User Id=dbUser;Password=*****;Server=oracleserver;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

Everything runs fine on my machine (sic), but when I tried to set the ws up on the quality server, I got the error on the title.


Solution

  • I got it working by following the steps in this ADO.NET link. Particularly,

    You need to remove the defaultConnectionFactory registration and to add the Entity Framework provider registration by registering it in the entityFramework section

    So the line defaultConnectionFactory must go

    <entityFramework>
      <providers>
        <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity.EF6, Version=9.6.696.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
      </providers>
    </entityFramework>
    

    Then, add the System.Data section. In my case it looks like this:

      <system.data>
        <DbProviderFactories>
          <remove invariant="Devart.Data.Oracle" />
          <add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=9.6.696.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
        </DbProviderFactories>
      </system.data>  
    

    If that still doesn't do the trick for you -- And it didn't for me -- try adding the following line to your context class:

    [DbConfigurationType(typeof(Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration))] //Add this line
    public partial class ADOEntities : DbContext
    

    You might want to create a partial class, incase you're using ADO, Devart, or other auto-generated entity model, to avoid having this piece of code in an auto-generated class