BlueshiftSoftware / EntityFrameworkCore

NoSQL providers for EntityFramework Core
Other
281 stars 57 forks source link

MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder Microsoft.EntityFrameworkCore.Metadata.Internal.InternalModelBuilder.Entity(System.Type, Microsoft.EntityFrameworkCore.Metadata.Internal.ConfigurationSource)' #21

Closed GavinHome closed 6 years ago

GavinHome commented 6 years ago

Hello, i have this issues: "MissingMethodException"

exception as follows:

An unhandled exception occurred while processing the request.

MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder Microsoft.EntityFrameworkCore.Metadata.Internal.InternalModelBuilder.Entity(System.Type, Microsoft.EntityFrameworkCore.Metadata.Internal.ConfigurationSource)'. Blueshift.EntityFrameworkCore.MongoDB.Metadata.Conventions.MongoDbRegisterKnownTypesConvention.Apply(InternalEntityTypeBuilder entityTypeBuilder)

############################################################ MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder Microsoft.EntityFrameworkCore.Metadata.Internal.InternalModelBuilder.Entity(System.Type, Microsoft.EntityFrameworkCore.Metadata.Internal.ConfigurationSource)'. Blueshift.EntityFrameworkCore.MongoDB.Metadata.Conventions.MongoDbRegisterKnownTypesConvention.Apply(InternalEntityTypeBuilder entityTypeBuilder) Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnEntityTypeAdded(InternalEntityTypeBuilder entityTypeBuilder) Microsoft.EntityFrameworkCore.Metadata.Internal.Model.AddEntityType(EntityType entityType) Microsoft.EntityFrameworkCore.Metadata.Internal.InternalModelBuilder.Entity(TypeIdentity type, ConfigurationSource configurationSource, bool throwOnQuery) Microsoft.EntityFrameworkCore.ModelBuilder.Entity(Type type) Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.FindSets(ModelBuilder modelBuilder, DbContext context) Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder, DbContext context) Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator) System.Collections.Concurrent.ConcurrentDictionary.GetOrAdd(TKey key, Func<TKey, TValue> valueFactory) Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel() Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model() lambda_method(Closure , ServiceProviderEngineScope ) Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider) Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() Microsoft.EntityFrameworkCore.DbContext.get_Model() Microsoft.EntityFrameworkCore.Internal.InternalDbSet.get_EntityType() Microsoft.EntityFrameworkCore.Internal.InternalDbSet.get_EntityQueryable() Microsoft.EntityFrameworkCore.Internal.InternalDbSet.System.Collections.Generic.IEnumerable.GetEnumerator() System.Collections.Generic.List.AddEnumerable(IEnumerable enumerable) System.Linq.Enumerable.ToList(IEnumerable source) Amazing.Api.Controllers.BlogsController.GetBlogs(ODataQueryOptions queryOptions) in BlogsController.cs + var result = db.blogs.ToList(); lambda_method(Closure , object , Object[] ) Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, Object[] parameters) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d12.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d10.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d14.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d22.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d17.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d15.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Builder.RouterMiddleware+d4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d7.MoveNext() ########################################################################## Show raw exception details System.MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder Microsoft.EntityFrameworkCore.Metadata.Internal.InternalModelBuilder.Entity(System.Type, Microsoft.EntityFrameworkCore.Metadata.Internal.ConfigurationSource)'. at Blueshift.EntityFrameworkCore.MongoDB.Metadata.Conventions.MongoDbRegisterKnownTypesConvention.Apply(InternalEntityTypeBuilder entityTypeBuilder) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnEntityTypeAdded(InternalEntityTypeBuilder entityTypeBuilder) at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.AddEntityType(EntityType entityType) at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalModelBuilder.Entity(TypeIdentity type, ConfigurationSource configurationSource, Boolean throwOnQuery) at Microsoft.EntityFrameworkCore.ModelBuilder.Entity(Type type) at Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.FindSets(ModelBuilder modelBuilder, DbContext context) at Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder, DbContext context) at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel() at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model() at lambda_method(Closure , ServiceProviderEngineScope ) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() at Microsoft.EntityFrameworkCore.DbContext.get_Model() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_EntityType() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_EntityQueryable() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator() at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Amazing.Api.Controllers.BlogsController.GetBlogs(ODataQueryOptions`1 queryOptions) in /Users/yangxiaoming/Amazing.vNext/Amazing.Api/Controllers/BlogsController.cs:line 35 at lambda_method(Closure , Object , Object[] ) at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.d4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d7.MoveNext()

########################################################################### How to solve it? Thanks.

crhairr commented 6 years ago

Hi Gavin,

I apologize for not updating the repo on a while. The first part of the year has been very busy and stressful for me!

The dependencies have changed, and I need to update them. I'll try to get around to it this weekend. Once the latest version of EFCore is stable, I should be able to cut the first official release and things like this shouldn't happen again.

crhairr commented 6 years ago

Also, pull requests are welcome!

UncleSamSwiss commented 6 years ago

Please see also the discussion around classes and methods internal to EF Core for another EF Core DB provider: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/497

It might be a good idea to get rid of any dependencies on those references.

crhairr commented 6 years ago

Yeah, I've been through this refactoring hurdle several times already...

However, I have to use a not insignificant amount of their "internal" classes in order to work around some of the assumptions the EF Core team makes in their API. They assume things like a relational database, or that data comes back as an indexed array of values. Since I'm wrapping the MongoDB C# driver, and letting it handle the Linq query translation, I have to work around a lot of assumptions about the shape of the returned data: namely that it's already a document/object instances. Because of the limited surface of the "external" API, I HAVE to use the "internal" code in order to work around their assumptions.

ErikEJ commented 6 years ago

I suggest that you raise this with the EF Core team

crhairr commented 6 years ago

@ErikEJ Someone from their team is supposedly working on some other Document DB provider, and wrapping an existing Linq provider for it. So I've been waiting on them to figure out their own problems and get them fixed. But you're probably right, it's probably time for me to pester them some more. Maybe some prodding will help them get out a Document DB layer that will clean up some of this mess, or at least a layer that more readily allows for wrapping an existing Linq provider. Either one would be huge for my provider.

ErikEJ commented 6 years ago

@crhairr You can look at the branch here: https://github.com/aspnet/EntityFrameworkCore/tree/cosmosdb

crhairr commented 6 years ago

I apologize for the delay!

This has been fixed. You should be able to pull the latest version from MyGet.