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

Duplication of one-to-many relationship using has/with pattern - configured from "both ends" #29

Open
definedrisk opened this issue Mar 9, 2021 · 0 comments

Comments

@definedrisk
Copy link

Excellent book, thank you!

modelBuilder.Entity<Category>()

Can lines 30-32 of NorthwindContextLib/Northwind.cs be commented out i.e. do they duplicate functionality provided by lines 81-83 ? Also for same reason lines lines 85-87 vs 111-113?

Please could you clarify, is this duplication and can these lines be removed? Otherwise in what situation would problems occur? What happens with duplication of relationships when specified using the has/with pattern in fluent?

More generally it would be very much appreciated if you could comment on the pros and cons of using fluent to specify these relationships vs relying upon One To Many Relationships Conventions:

It seems that the relationship is fully defined already by convention due to both ends being present in the entity classes i.e. public ICollection<Product> Products { get; set; } in Category and public Category Category { get; set; } in Product along with the foreign key public int? CategoryID { get; set; } in Product.

If so maybe we could add a comment to this affect - such that the code demonstrates both relationships by convention and by fluent API?

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

No branches or pull requests

1 participant