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

Partial fix for 6674. #20271

Merged
merged 2 commits into from
Mar 14, 2020
Merged

Partial fix for 6674. #20271

merged 2 commits into from
Mar 14, 2020

Conversation

lajones
Copy link
Contributor

@lajones lajones commented Mar 13, 2020

Partial fix for #6674

Created new Navigation() calls directly on EntityBuilder. Added tests for OneToMany, ManyToOne, ManyToMany, OneToOne and principal side of the Owned Type.

Things remaining:

@lajones lajones self-assigned this Mar 13, 2020
@lajones
Copy link
Contributor Author

lajones commented Mar 13, 2020

@AndriySvyryd See also #20276 for being able to configure the dependent side navigation of an Owned-type.

@AndriySvyryd
Copy link
Member

I pushed a commit for what I was talking about

@lajones
Copy link
Contributor Author

lajones commented Mar 13, 2020

@AndriySvyryd Ah - understand now. Thanks.

@smitpatel
Copy link
Member

Removing the old way of doing it (see #20195).

Not in this PR. Where are those changes?

@lajones
Copy link
Contributor Author

lajones commented Mar 13, 2020

@smitpatel I'm not removing the old way until we're agreed this is the way forward.

@lajones
Copy link
Contributor Author

lajones commented Mar 13, 2020

@smitpatel The tests are renamed in the other PR (#20276) - where we allow you to specify the dependent end as well.

@AndriySvyryd
Copy link
Member

AndriySvyryd commented Mar 13, 2020

Squash the commits. Might as well include #20276 too

@lajones
Copy link
Contributor Author

lajones commented Mar 13, 2020

@Andriy Need to change the names in the tests to get rid of NavigationIdentityBuilder there too. Then will do.

…ntityBuilder. Added OnetoMany, ManyToOne, ManyToMany, OneToOne and principal side of the Owned Type tests.
Builder = ((Navigation)navigation).Builder;
NavBuilder = (navigationOrSkipNavigation as Navigation)?.Builder;
SkipNavBuilder = (navigationOrSkipNavigation as SkipNavigation)?.Builder;
Metadata = (IMutableNavigationBase)NavBuilder?.Metadata ?? SkipNavBuilder?.Metadata;
Copy link
Member

Choose a reason for hiding this comment

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

The Metadata property should be computed, it's rarely accessed.
If you are going to store it, then assign from navigationOrSkipNavigation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean (navigationOrSkipNavigation as Navigation)?.Builder.Metadata ?? (navigationOrSkipNavigation as SkipNavigation)?.Builder.Metadata? That seems worse?

Copy link
Member

Choose a reason for hiding this comment

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

Metadata = navigationOrSkipNavigation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh!

Copy link
Contributor Author

@lajones lajones Mar 13, 2020

Choose a reason for hiding this comment

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

Just FMI why don't we do this on all of the builders?

Copy link
Member

Choose a reason for hiding this comment

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

It uses more memory and is completely unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want to just go back to doing it your way then? It looked good to me but I'm happy to revert.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer that, but I don't feel strongly


modelBuilder.Entity<ManyToManyNavPrincipal>()
.HasMany<NavDependent>("Dependents")
.WithMany("ManyToManyPrincipals");
Copy link
Member

Choose a reason for hiding this comment

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

You should use names that are different from the CLR properties to get better coverage.

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 tried what I thought you meant and I get The navigation property 'NonClrDependents' cannot be added to the entity type 'ManyToManyNavPrincipal' because there is no corresponding CLR property on the underlying type and navigations properties cannot be added to shadow state.
Can you explain more?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you also need to use shadow entity types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's add that separately. It sounds likes that going to be tricky given the error above "cannot be added to shadow state". I'll add it to the issue to make sure I don't forget. I want to get feedback that the rest of the team likes this new approach before I flesh out the tests.

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.

3 participants