Skip to content

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

@definedrisk

Description

@definedrisk

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions