SQL, MVC, Entity Framework

Posted by Anthony on Stack Overflow See other posts from Stack Overflow or by Anthony
Published on 2010-04-25T13:01:35Z Indexed on 2010/04/25 13:03 UTC
Read the original article Hit count: 305

Filed under:
|
|
|

Hi

Im using the above technologies and have ran into what I presume is a design issue I have made.

I have an Artwork table in my DB and have been able to add art (I now think of these as Digital Products) to a shopping cart + CartLine table fine. The system I have that adds art to galleries and user accounts etc works fine.

Now the client wants to sell T-shirts, Mugs and Pens etc, 'HardwareProducts' so I have created a 'HardwareProducts' table.

Now I have two different product types in two tables. I use GUID's as the PK's in both the HardwareProducts table and Artwork table. When a customer adds an item to their cart I store the GUID in the ProductID column in the CartItems table.

The issue is the database will not know which table to reference when I bring the LineItem object up through my ORM to the front end.

In OOP I can see how you would have a base class of Product, and then a DigitalProduct class and HardwareProduct class drived from it, but how do you model this in SQL Server and the Entity Framework please, or is there another way?

© Stack Overflow or respective owner

Related posts about polymorphism

Related posts about orm