New Posts New Posts RSS Feed: relationship mapping on foreign keys
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

relationship mapping on foreign keys

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: relationship mapping on foreign keys
    Posted: 10-Feb-2009 at 12:01pm

First I should say that because DevForce EF uses the ADO.NET Entity Framework for the underlying entity model that we're dependent on the rules enforced by EF, which are in general somewhat strict.  What you're seeing here is a message from EF as you build your model via the Entity Data Model designer, so the error itself is not raised by DevForce. 

Apparently this error is a known limitation in EF - here's what a Microsoft engineer said on the ADO.NET EF forum:
Yes, this is a restriction of the current version of the EF: It does not allow foreign keys which are only partly inside of the primary key. It is not a limitation of the tools, but of the framework itself."
 
In your situation I don't know if it would make sense to a) not mark the Employee.OrganizationId as part of the primary key, or b) add OrganizationId to the Person table, or c) add surrogate keys to these tables, or d) leave the association unmapped. 
 
Back to Top
egoren View Drop Down
Newbie
Newbie


Joined: 09-Feb-2009
Posts: 2
Post Options Post Options   Quote egoren Quote  Post ReplyReply Direct Link To This Post Posted: 09-Feb-2009 at 2:37pm
Hi,
 
We are having a problem with DevForce EF.
We have the following database schema:
Person { *PersonId }
Employee { *PersonId, *OrganizationId, PositionId }
Position { *PositionId, *OrganizationId }
[The * represents the primary key(s)]
When adding the table in the ebmx diagram, the relation between Employee and Position is not created and we receive this error :
warning 6030: The relationship 'FK_Employee_Position' uses the set of foreign keys '{OrganizationId, PositionId}' that are partially contained in the set of primary keys '{OrganizationId, PersonId}' of the table 'Employee'. The set of foreign keys must be fully contained in the set of primary keys, or fully not contained in the set of primary keys to be mapped to a model.
Is there a way to create this relation in DevForce EF like we could (and do) in DevForce Classic?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down