Code First: Exception - no DbProviderService

Code First: Exception - no DbProviderService

Postby christian_bertram » Mon 22 Jun 2015 08:45

I installed the professional trial and put the provider information in the app config like this and used it in my connection:

Code: Select all
<provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.4.437.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />


All i get is the following error:

The 'Instance' member of the Entity Framework provider type 'Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.4.437.0, Culture=neutral, PublicKeyToken=09af7300eec23701' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information.


Database : Oracle 11g2
Visual Studio 2013

It works with the Oracle.ManagedDataAccess.Client provider

Whats wrong? Did i forgot something?


app.config file:

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  </configSections>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.4.437.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
   
  </entityFramework>
<connectionStrings><add name="OracleDbContext" providerName="Devart.Data.Oracle" connectionString="..." />
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<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.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no" />
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.121.1.0" newVersion="4.121.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " />
</dataSources>
</version>
</oracle.manageddataaccess.client>
</configuration>
christian_bertram
 
Posts: 16
Joined: Mon 22 Jun 2015 08:38

Re: Code First: Exception - no DbProviderService

Postby Shalex » Mon 22 Jun 2015 12:46

Please note that the revision number of provider in the entityFramework section should be *.6 but it is *.0 in DbProviderFactories:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.4.437.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
  </entityFramework>
  <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=8.4.437.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>

Replace 8.4.437 here with your current version of dotConnect for Oracle.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44

Re: Code First: Exception - no DbProviderService

Postby christian_bertram » Mon 22 Jun 2015 13:37

Thank you, that was the whole problem. Now it`s working

I took in from the Devart.Data.Oracle dll .
Why is it not the same number and where can i find the correct version number of the provider?
christian_bertram
 
Posts: 16
Joined: Mon 22 Jun 2015 08:38

Re: Code First: Exception - no DbProviderService

Postby Shalex » Tue 23 Jun 2015 06:56

christian_bertram wrote:Why is it not the same number
Because there are different versions of Devart.Data.Oracle.Entity.dll:
"C:\Program Files (x86)\Devart\dotConnect\Oracle\Entity\EF1\"
"C:\Program Files (x86)\Devart\dotConnect\Oracle\Entity\EF4\"
"C:\Program Files (x86)\Devart\dotConnect\Oracle\Entity\EF5\"
"C:\Program Files (x86)\Devart\dotConnect\Oracle\Entity\EF6\"

christian_bertram wrote:and where can i find the correct version number of the provider?
Please navigate to the Tools > Oracle > About menu.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle