Sergey Durnov

Sergey Durnov

  • NA
  • 27
  • 13.2k

EF model from 2 tables connected with junction table - Model don’t see records and changes in junction table

Feb 12 2010 8:31 AM

I have several tables in my SQL2008 DB, Managers(ManagerID is a PK, incremental) and Customers(CustomerID is a PK, incremental) are among them. All ID columns are int. They are connected with junction table ManagersCustomers(fields: CustomerID is a PK, ManagerID) and there are relations: from CustomerID in Customers to same in junction table with delete cascade rule and from ManagerID in Managers to same in junction table with delete cascade too. So I have Managers 0..1 to * Customers relation in my edmx model after generating it from my DB and I can see this relation is mapped to junction table. I tested junction table in SQL Server Management Studio, it works correctly. Ok. In my app I have 2 parts - edmx model on server side connected with client side through WCF Data Service. In client part I'm creating instance of my entities class, and in debug mode I can watch entities class instance's data. Both entities Customers and Managers are filled with data correctly, but in navigation fields I can see only 0. For example I have Customer with CustomerID = 1 connected with Manager with ManagerID=3 and there is a record in junction table. So, if it would work correctly, I would see my manager in navigation field of Customers entity and same with customer nav field in Managers entity. But I can see only zeros.