I'm working on many to many relationship for BreezeJS/WebAPI/OData like this:
Metadata: and get data with dataContext.Users.Include("Customers") is fine: but why in result user object doesn't have customers navigation property:
I read this article but no luck still can't use user.customers()
I'm totally stuck, please help me.
Thanks in advance.
EntityFramework knows about the UserCustomers
table, even though it is not exposed as an entity. But Breeze only knows what is in the metadata, and EF will not generate Breeze metadata for UserCustomers
unless it is exposed as an entity. (Often this is what you want anyway, because it allows you to add additional data to the relationship table, such as the date that the UserCustomer relationship was added).
The many-to-many mapping table, UserCustomers
, must be exposed as an entity. Then your metadata will include that entity, and your Customer
entity will have a UserCustomers
collection, and your User
entity will have a UserCustomers
collection.
On the client, if you want to create a new relationship between a User and Customer, you can add a new UserCustomer entity to related them.