EF 6 Beta 1, Oracle, Web API - Wrong provider version

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
k.ewin
Posts: 3
Joined: Thu 11 Jul 2013 08:03

EF 6 Beta 1, Oracle, Web API - Wrong provider version

Post by k.ewin » Wed 17 Jul 2013 13:21

Hi,

I am using dotConnect in a Web API project that uses EF 6 Beta 1. On DbContext creation I get the following exception:

Code: Select all

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=The 'Instance' member of the Entity Framework provider type 'Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=7.7.276.0, Culture=neutral, PublicKeyToken=09af7300eec23701' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must extend from this class and the 'Instance' member must return the Singleton instance of the provider.
  Source=EntityFramework
  StackTrace:
       bei System.Data.Entity.Config.ProviderServicesFactory.GetInstance(Type providerType)
       bei System.Data.Entity.Config.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName)
       bei System.Data.Entity.Internal.AppConfig.<.ctor>b__2(ProviderElement e)
       bei System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       bei System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       bei System.Data.Entity.Internal.AppConfig.<.ctor>b__1()
       bei System.Lazy`1.CreateValue()
       bei System.Lazy`1.LazyInitValue()
       bei System.Lazy`1.get_Value()
       bei System.Data.Entity.Internal.AppConfig.get_DbProviderServices()
       bei System.Data.Entity.Config.AppConfigDependencyResolver.RegisterDbProviderServices()
       bei System.Data.Entity.Config.AppConfigDependencyResolver.GetServiceFactory(Type type, String name)
       bei System.Data.Entity.Config.AppConfigDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 t)
       bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
       bei System.Data.Entity.Config.AppConfigDependencyResolver.GetService(Type type, Object key)
       bei System.Data.Entity.Config.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r)
       bei System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
       bei System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
       bei System.Data.Entity.Config.ResolverChain.GetService(Type type, Object key)
       bei System.Data.Entity.Config.CompositeResolver`2.GetService(Type type, Object key)
       bei System.Data.Entity.Config.IDbDependencyResolverExtensions.GetService[T](IDbDependencyResolver resolver, Object key)
       bei System.Data.Entity.Config.InternalConfiguration.GetService[TService](Object key)
       bei System.Data.Entity.Config.DbConfiguration.GetService[TService](Object key)
       bei System.Data.Entity.Config.DbConfiguration.GetService[TService]()
       bei System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)
       bei System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
       bei Kaba.Production.Api.DataAccess.Models.Context..ctor() in c:\Projects\Kaba.Production\Kaba.Production.Api.DataAccess\Models\Context.cs:Zeile 14.
       bei Kaba.Production.Api.Controllers.ProductionOrderInfoController..ctor() in c:\Projects\Kaba.Production\Kaba.Production.Api\Controllers\ProductionOrderInfoController.cs:Zeile 14.
       bei lambda_method(Closure )
       bei System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
  InnerException: 
It seems that the wrong version of Devart.Data.Oracle.Entity is used. 7.7.276.6 should be used for EF 6. In my Web.config file I have specified the correct version. I have no clue, why the wrong one is used.

My Web.config: (EF configuration at the end)

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301879
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <authentication mode="None"/>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
      <remove name="OPTIONSVerbHandler"/>
      <remove name="TRACEVerbHandler"/>
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="GeoAPI" publicKeyToken="A1A0DA7DEF465678" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-1.7.1.0" newVersion="1.7.1.0"/>
			</dependentAssembly>
	      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <connectionStrings>
    <add name="Context" connectionString="User Id=*******;Password=*******;Server=*******;Direct=True;Service Name=*******;Persist Security Info=True;" providerName="Devart.Data.Oracle"/>
  </connectionStrings>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=7.7.267.6, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
    </providers>
  </entityFramework>
</configuration>
Any idea what I am doing wrong?

k.ewin
Posts: 3
Joined: Thu 11 Jul 2013 08:03

Re: EF 6 Beta 1, Oracle, Web API - Wrong provider version

Post by k.ewin » Wed 17 Jul 2013 14:59

Meanwhile I have found a workaround, by using the new EF6 code based configuration feature. I have commented out the provider in Web.config. I added a reference to the appropriate Devart.Data.Oracle.Entity assembly and a configuration class:

Code: Select all

public class MyDbConfiguration : DbConfiguration
    {
        public MyDbConfiguration()
        {
            this.AddDbProviderServices("Devart.Data.Oracle", new Devart.Data.Oracle.Entity.OracleEntityProviderServices());
        }

    }
This works well. Still don't know why the configuration in Web.config did not work.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: EF 6 Beta 1, Oracle, Web API - Wrong provider version

Post by Shalex » Thu 18 Jul 2013 07:45

k.ewin wrote:Message=The 'Instance' member of the Entity Framework provider type 'Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=7.7.276.0, ...
Your web.config includes registration of the 7.7.267.6 version instead of 7.7.276.6. As a result, the policy.*.Devart.* file redirects the call to 7.7.276.0. Set an actual (7.7.276.6) version of Devart.Data.Oracle.Entity.OracleEntityProviderServices in web.config.

Post Reply