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

Query: Disallow tracking queries for owned entites without their owners #16997

Merged
merged 1 commit into from
Aug 7, 2019

Conversation

smitpatel
Copy link
Contributor

Resolves #13036

@smitpatel smitpatel force-pushed the smit/DoNoTrack13036 branch from c1466f3 to 95cf29a Compare August 6, 2019 23:50
@smitpatel smitpatel requested a review from ajcvickers August 6, 2019 23:50
@smitpatel smitpatel merged commit c8e2522 into release/3.0 Aug 7, 2019
@ghost ghost deleted the smit/DoNoTrack13036 branch August 7, 2019 00:29
foreach (var entityType in _visitedEntityTypes)
{
if ((entityType.HasDefiningNavigation()
&& !containsOwner(entityType.DefiningEntityType))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defining entity isn't always the owner. We shouldn't prevent weak entities to be tracked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it been a while we all had discussion about weak vs owned.
Filed #16999 to discuss when you are back at work.

Copy link

@salaros salaros Sep 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR breaks completely scenarios when an entity inherits an owned entity from its base class:

[Owned]
public class OwnedEntity
{
	public string Prop { get; set; }
}

public class A 
{
	public string Foo { get; set; }
}

public class B : A
{
	public string Bar { get; set; }
}

// ...

builder
	.OwnsOne(a => a.AuditLog); //<-- works only for base type

// ...

await dbContext.Set<B>().SingleOrDefaultAsync(e => e.Bar == bar); //<-- throws InvalidOperationException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disallow tracking queries for owned entities without their owners
4 participants