views:

179

answers:

2

I have an Entity Framework model with table Employees. Each employee has a SupervisorId, which points to another record in the same Employees table. The entity model VS inferred from my DB design looked fine, but I could not update or insert records for the table with the self-reference. I have taken to using a view of the Employees table for the Supervisors table, but I cannot add an FK constraint to a view in the database. How can I do this, or achieve the same effect, in the EF designer?

At worst I can skip the FK constrain, but would like to know how to use and populated a standard or custom combobox so the Employee form still offers a choice of Supervisors when editing.

+2  A: 
marc_s
Thanks @Marc, but how do I relate the association's navigation properties with actual objects, e.g. in your example, how do I popall the Entries for a Contract?
ProfK
Yeah, sorry - that doesn't seem to work - it still insists on being mapped to a FK-relationship in the database :-( I was hoping it would be able to resolve that association in the conceptual model alone - no luck :-(
marc_s
+1 For trying, but my problem isn't solved, so sorry, close but no Accept, hehe.
ProfK
A: 

I have the same problem. The Association is added, but I can't add foreign key to the entity

SERG