EntityFramework-Effort: EffortProviderServices doesn't inherit from 'System.Data.Entity.Core.Common.DbProviderServices'

I get a System.InvalidOperationException on the second line:

    var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());
    ApplicationDbContext db = new ApplicationDbContext(connection);

It happens inside the Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext<ApplicationUser>.ctor I’m deriving from:

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext(DbConnection connection) : base(connection, false)
        {
        }
    }

Here’s the complete exception

System.InvalidOperationException occurred
  HResult=-2146233079
  Message=The 'Instance' member of the Entity Framework provider type 'Effort.Provider.EffortProviderServices, Effort, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6a46696d54971e6d' 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.
  Source=EntityFramework
  StackTrace:
       at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(Type providerType)
       at System.Data.Entity.Internal.AppConfig.<.ctor>b__2(ProviderElement e)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at System.Lazy`1.CreateValue()
       at System.Lazy`1.LazyInitValue()
       at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.RegisterDbProviderServices()
       at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name)
       at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
       at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key)
       at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
       at System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key)
       at System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService[T](IDbDependencyResolver resolver)
       at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)
       at Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext`1..ctor(DbConnection existingConnection, Boolean contextOwnsConnection)
       at MyProject.ApplicationDbContext..ctor(DbConnection connection) in ..\MyProject\ApplicationDbContext.cs:Zeile 16.
  InnerException: 

I tried to fix the App.config but it didn’t help

    <?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 -->
      </configSections>
      <entityFramework>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Hello all,

Just to let you know that we are currently preparing a release for this fix.

Finally after thinking about it, simply using a different key to strongly name the assembly may be the best solution.

No need to rename the assembly, namespace or whatever since they will now be considered as a different assembly which they are anyway!

The Effort.EF6 will keep the same signing key while the Effort will now use a new key.

Best Regards,

Jonathan

This is still an issue. The issue is that they have the same DLL filename.