Efcore: ThenInclude Method not found

Created on 24 Nov 2016  路  13Comments  路  Source: dotnet/efcore

The issue

After upgrade to 1.1.0. Run Query to load navigation property then got the error as below.

Code

   var all = db.Category.Include(c => c.CategoryPics).ThenInclude(p => p.Picture);
       var result = all.ToList();

Error

MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Query.IIncludableQueryable`2<!!0,!!2> 
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ThenInclude(Microsoft.EntityFrameworkCore.Query.IIncludableQueryable`2<!!0,System.Collections.Generic.ICollection`1<!!1>>, System.Linq.Expressions.Expression`1<System.Func`2<!!1,!!2>>)'.

Further technical details

EF Core version: 1.1.0
Operating system:
Visual Studio version: VS 2015 Update 3

Other details about my project setup:

closed-fixed type-bug

Most helpful comment

Re-opening to discuss in triage. This is a known binary breaking change; we may consider fixing it in a patch release.

All 13 comments

Sorry~~
Please close this issue.This issue is my library project are forgot upgrade and still stay on 1.0.0.

I just ran into this issue.

I have a ASP.NET Core 1.0 host app that references a library (netstandard14). The library references EF Core 1.0. The library has no SqlServer dependencies (just uses a DbContext). The host puts the DbContext in DI and configures SqlServer as the provider.

I then update the host app to ASP.NET Core 1.1 (and EF Core 1.1 and SqlServer 1.1), but still rely upon the same library that depends on EF Core 1.0. I run my code and now get this exception:

MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Query.IIncludableQueryable`2<!!0,!!2> Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ThenInclude(Microsoft.EntityFrameworkCore.Query.IIncludableQueryable`2<!!0,System.Collections.Generic.ICollection`1<!!1>>, System.Linq.Expressions.Expression`1<System.Func`2<!!1,!!2>>)'.
IdentityServer4.EntityFramework.Stores.ResourceStore.GetAllResources()
IdentityServer4.Stores.IResourceStoreExtensions+<GetAllEnabledResourcesAsync>d__2.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Endpoints.DiscoveryEndpoint+<ExecuteDiscoDocAsync>d__9.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.IdentityServerMiddleware+<Invoke>d__3.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.FederatedSignOutMiddleware+<Invoke>d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.AuthenticationMiddleware+<Invoke>d__2.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+<Invoke>d__18.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+<Invoke>d__18.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware+<Invoke>d__7.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
IdentityServer4.Hosting.BaseUrlMiddleware+<Invoke>d__2.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+<Invoke>d__7.MoveNext()

As an experiment I then updated the library to EF 1.1 and it all worked. This leads me to believe there was a binary and thus breaking change in EF 1.1.

The solution here can't be for me up update my library to EF 1.1, since I am only building the library (the host mentioned above is only for testing). The actual hosts are developed by my customers/consumers and I don't have control over which version they want to use.

This was originally reported to me here: https://github.com/IdentityServer/IdentityServer4/issues/518 and here: https://github.com/IdentityServer/IdentityServer4.EntityFramework/issues/38

Re-opening to discuss in triage. This is a known binary breaking change; we may consider fixing it in a patch release.

I was informed today that .NET Core and ASP.NET Core (and then presumably EF Core) are not following semantic versioning across the LTS and current release paths. Thus this issue could be closed as updates from 1.0.x to 1.1.x are not expected to binary compatible. I'd ask you to confirm that internally if what I was told matches your expectations. The worst case scenario would be that some libraries/projects from Microsoft decide to do semver and others do not.

I have also just hit this issue, however I am only trying to go from 1.0.0 to 1.0.1..

@brockallen That's incorrect. We do follow semantic versions and any binary breaking changes we make between 2 versions that are supposed to be compatible is a mistake and should be fixed.

So I misread the email -- 1.0 to 1.1 was not meant to be semver, but 1.1 and beyond is. Is that closer to accurate?

fyi I have had good success with this library for performing automated checks of your public API, to detect breaking changes. Might be worth considering: https://github.com/JakeGinnivan/ApiApprover

Agreed, we will look at making this binary compatible in a patch

So I misread the email -- 1.0 to 1.1 was not meant to be semver, but 1.1 and beyond is. Is that closer to accurate?

Major versions, not point releases or patches of those point releases. So 1.1 will be compatible with 1.2 etc. Up until the next major. The only places this doesn't apply are inside of the .Internal namespaces.

This is fixed and merged. Leaving the bug open for patch approval.

Justification: Assemblies compiled against 1.0 assembly will throw when using 1.1 assembly unless they are re-built.
Risk: Low--Adding back in the API that was removed; functionality is unchanged.

This patch bug is approved. Please use the normal code review process w/ a PR and make sure the fix is in the correct branch, then close the bug and mark it as done.

Was this page helpful?
0 / 5 - 0 ratings