You are working on an ASP.NET Core application and need to model a scenario where each Order can have multiple OrderDetails, but each OrderDetail belongs to one Order. How would you model this relationship using Entity Framework Core?

  • One-to-Many Relationship
  • Many-to-Many Relationship
  • One-to-One Relationship
  • Self-Referencing Relationship
In this scenario, you should use a One-to-Many Relationship. Each Order can have multiple OrderDetails, creating a parent-child relationship. You can achieve this by defining a navigation property in the Order class pointing to a collection of OrderDetails, and a reference property in the OrderDetail class pointing back to the Order.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *