Problems mapping inheritance in Entity Framework

c# entity-framework


I encountered a problem while attempting to learn EF. Let's simplify my database, which consists of 4 tables:

1) Items(NodeID, other fields), 
2) Nodes(NodeID, extra), 
3) Recipient(RecipientID, others) 
4) NodesRecipient(RecipientID, NodeID).

Item-Node has a 1:1 relationship, and NodeID is the primary key. Recipient has two primary keys: RecipientID for Recipient and NodeID for Nodes. See the diagram below.Node inherits from item Using VS 2012, I produced an EF model from the aforementioned database. After building the model, I made Node a descendant of Items by designating Item as its base and removed their one-to-one relationship. Additionally, since I don't want to directly manipulate that entity, I made Items abstract.

The compiler is disgruntled:

Error 1 Error 3024: Problem in mapping fragments starting at line 266:Must specify mapping for all key properties (Items.nodeID) of the EntitySet Items.

However, the compiler would not complain if I did not utilize inheritance, and it was fine.

No inheritance

What exactly is my problem, and how can I solve it? It would be wonderful if EF permitted inheritance, and I believe it does given that I can name the base class. However, I believe there may be some links I overlooked while reading the Microsoft documentation.

5/14/2018 6:21:48 PM

Accepted Answer

12/17/2013 4:14:29 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow