Last post Jan 16, 2011 06:21 PM by boxim
Feb 11, 2010 04:44 PM|vinneyk|LINK
I am having some issues with my base class inheritance. I am currently employing Table per Type Inheritance for the following tables:
- Member ID (PK)
- First Name
- Last Name
- Member ID (FK)
- Office Hours
My Entity Data Model defines "Member" as the base class for both Students and Instructors, since members can be both students as well as instructors simultaneously. The problem, however, occurs when I attempt to get a list of Members objects. Because the
database contains members who are indeed students AND instructors, the following exception is thrown:
All objects in the EntitySet 'CountyCollegeEntities.BaseMembers' must have unique primary keys. However, an instance of type 'CountyCollege.NET.Administrator' and an instance of type 'CountyCollege.NET.Student' both have the same primary key value, 'EntitySet=BaseMembers;ID=10016'.
I am beginning to think that I made a mistake by building these classes to inherit from Member although it has been ideal up until this point. But before I start ripping up all my existing code to remove this inheritance, I thought I would see if anyone
has any tricks that would make this work. Any advice as to either how I can get around this error or a more appropriate way to structure my classes would be very much appreciated.
Entity Data Model
table per type inheritance
Feb 18, 2010 02:02 AM|Wencui Qian - MSFT|LINK
Please try to post it here to get more help:
Jan 16, 2011 06:21 PM|boxim|LINK
Did you ever find out how to do this, got exactly the same issue?