question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigation property 'Claims' on entity of type 'User' cannot be loaded because the entity is not being tracked.

See original GitHub issue

Abp Version:3.6.2 .Net Core Version:2.1.0 Ef Core Version:2.1

When I upgrade to .net core 2.1, after the user login in, idle for a period of time (without any operation and not close browser), it will throw the following error:

InvalidOperationException: Navigation property 'Claims' on entity of type 'User' cannot be loaded because the entity is not being tracked. Navigation properties can only be loaded for tracked entities.

image

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

9reactions
malimingcommented, Jun 8, 2018

Identity 2.1 made some changes. It re-registered with ISecurityStampValidator

AddSignInManagerDeps

It covers AddAbpSecurityStampValidator<UserSecurityStampValidator>()

So only need to change the registration order can be solved.

 return services.AddAbpIdentity<Tenant, User, Role>()
                .AddAbpTenantManager<TenantManager>()
                .AddAbpUserManager<UserManager>()
                .AddAbpRoleManager<RoleManager>()
                .AddAbpEditionManager<AbpEditionManager>()
                .AddAbpUserStore<UserStore>()
                .AddAbpRoleStore<RoleStore>()
                
                .AddAbpSignInManager<UserSignInManager>()

                .AddAbpUserClaimsPrincipalFactory<UserClaimsPrincipalFactory>()
                .AddAbpSecurityStampValidator<UserSecurityStampValidator>()
                .AddPermissionChecker<UserPermissionChecker>()

                //.AddAbpSignInManager<UserSignInManager>()

                .AddFeatureValueStore<AbpFeatureValueStore<Tenant, User>>()
                .AddDefaultTokenProviders();
1reaction
Greatsampscommented, Jun 7, 2018

Hi,

This is happening for us also after upgrade from 3.5.x to 3.7. We are using Kesteral hosting, so anything to do with IIS recycling can be discounted. (we are still in development only)

What i have found solves the problem is to delete all cookies and restart the browser, at this point you are asked to log in again, and all is well-- clearly not a production solution.

Will update if i learn more about how to reproduce.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to load navigation properties in new entity
I have tried to use _context.Entry(statistic).Reference(s => s.User).Load(); method and got exception while submitting entity to database: ...
Read more >
Tracking vs. No-Tracking Queries - EF Core
EF Core also fixes up navigation properties between the entities in a tracking query result and the entities that are in the change...
Read more >
The navigation 'IdentityUser.Claims' cannot be loaded ...
Claims ' cannot be loaded because the entity is not being tracked. Navigations can only be loaded for tracked entities. #4771.
Read more >
How do you manage non-loaded navigation properties in ...
If you try to use a navigation property, which is not yet loaded, you'll get a NullReferenceException at runtime.
Read more >
Navigation Property With Code First ...
In this article, you will learn about Navigation Property with code first and navigation property in Entity Framework.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found