0

Entity framework does not seem to lazy load related records if the key is unique and non-clustered. Just wanted to know if I am doing something wrong.

Say I have two tables - Employee and EmployeeTransactions.

EmployeeID is UNIQUE NONCLUSTERED but not the primary key of the table.

Assume for the question's sake, it is generated by another data base and inserted into the employee table.

However, most other tables have an EmployeeID which is a foreign key to table Employees

  --Table Employee 
  DBGEneratedPK
  EmployeeID (Unique NonClustered, Indexed)

  -- Table EmployeeTransactions 
  TransactionID (PK Clustered)
  EMployeeID (FK into Table A)
  Other columns

Now, when I use entity framework to retreive an employee it does not show me the option of lazy loading employeetransactions?

  employee.employeetransactions

Is this a limitation of EF?

2
  • Depends on your mappings. Please show the details. Commented Dec 2, 2012 at 21:53
  • I am just using the generated edmx. Should I do some explicit maping in the edmx? Commented Dec 3, 2012 at 7:44

1 Answer 1

1

Yes it is limitation of EF. EF supports relations only when the key in principal table is a primary key. Just unique keys are currently not supported.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.