Entity Design in C# EF - linking only one table at a time

Viewed 28

This is a difficult question to formulate, so I'll do my best. I'm trying to come up with the most sensible DB design to represent the following scenario:

We have an object represented by Entity A which has certain dimensions. The issue is, depending on the type of object (which is a property of Entity A) the dimensions are different and have different designations.

For argument sake let's say in our web application a user wants to create a new object and they can choose either a cylinder or a box. The cylinder will have 2required dimensions (diameter and length), the box will have 3 (height, width, depth).

Initial idea was to have two separate entities CylinderDimensions and BoxDimensions which are linked to Entity A through FK constraint; the Id of Entity A stored as part of the Dimension entities. But how would this work with the EF in C#? Would we need two separate properties set up in the model and ensure only one of them actually has value at any time?

0 Answers
Related