Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading owned object fails #16188

Closed
IvanZheng opened this issue Jun 21, 2019 · 7 comments
Closed

Loading owned object fails #16188

IvanZheng opened this issue Jun 21, 2019 · 7 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@IvanZheng
Copy link

IvanZheng commented Jun 21, 2019

Lazy Loading owned object and Entry(entity).Reference(e => e.OwnedObject).LoadAsync() are failed. Only dbContext.DbSet.Include(e => e.OwnedObject).FirstOrDefaultAsync() works.

BTW, they fail on EF Core version: 3.0.0-preview6.19304.10 but work on EntityFramerworkCore 3.0.0-preview5.19227.1.

Exception message:
Cannot create a DbSet for 'UserProfile' because it is configured as an owned entity type and should be accessed through the defining entities.
Stack trace:
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
   at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Query(INavigation navigation, Object[] keyValues)
   at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Load(INavigation navigation, InternalEntityEntry entry)
   at Microsoft.EntityFrameworkCore.Internal.LazyLoader.Load(Object entity, String navigationName)
   at Microsoft.EntityFrameworkCore.Proxies.Internal.LazyLoadingInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.UserProxy.get_UserProfile()

Further technical details

EF Core version: 3.0.0-preview6.19304.10
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system:
IDE: (e.g. Visual Studio 2019 16.1.3)

@ibasin
Copy link

ibasin commented Jul 12, 2019

I ran into the same issue and am waiting for the resolution (hopefully soon).

While at it, I think it might be useful to remove the current requirement (which I think is a bug) to mark Owned type properties as virtual if Lazy Loading is enabled. I think the bug might even be related to treating Owned properties as Nav properties when lazy loading is enabled.

Just my 2 cents...

@smitpatel smitpatel removed their assignment Aug 7, 2019
@ibasin
Copy link

ibasin commented Aug 14, 2019

Just wondering if this issue has been fixed. It seems to be still open.

@AndriySvyryd
Copy link
Member

@ibasin This hasn't been fixed yet and we currently can't provide an estimate as to when it will be.

@AndriySvyryd AndriySvyryd modified the milestones: Backlog, 3.1.0 Sep 5, 2019
@AndriySvyryd
Copy link
Member

Related to #16186

@IvanZheng
Copy link
Author

IvanZheng commented Sep 17, 2019

@ibasin @AndriySvyryd It works with "EF Core 3.0.0-rc1.19456.14" . But Entry.Reload doesn't reload owned objects #16186 .

@AndriySvyryd
Copy link
Member

Good to hear

@AndriySvyryd AndriySvyryd added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed punted-for-3.0 type-bug labels Sep 17, 2019
@AndriySvyryd AndriySvyryd modified the milestones: 3.1.0, 3.0.0 Sep 17, 2019
@ibasin
Copy link

ibasin commented Sep 17, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants