I'm trying to update Many to Many relationships from the client to the server while creating an OData / Entity Framework client server application.
The WCF 5.6, Entity Framework 6, and VS2013 are used to create the OData server.
The database consists of just three tables: Users, Permissions, and UsersPermissions for joining.
The joining of the UsersPermissions table is abstracted away by Entity Framework 6 such that only the Users and Permissions entities are left.
Using LINQ, I can easily query a user's rights from a client. I can also query Users from Permissions, demonstrating how useful the many-to-many relationship is for reading from.
Nothing happens if I try to build a relationship from the client, such adding a new permission for a user. No data is altered in the joining table in the database, and there is no transmission to the server.
This occurs whether I use LinqPad to run the query against my OData source or try to add a privilege to a user in my client application.
I'm using the following LINQ, which is from LinqPad:
// Get permission var Permission = (from p in Permissions where p.PermissionId == 1 select p).SingleOrDefault(); // Get user var User = (from u in Users where u.UserId == 1 select u).SingleOrDefault(); // Add permission to user User.Permissions.Add(Permission); SaveChanges();
I've made an entirely new OData server application but still have the same issue.
If I run the aforementioned LINQ query inside the OData server app, it runs as anticipated and adds the entry to UsersPermissions.
So it would appear that updating a many-to-many relationship via an OData client is the only scenario where the issue occurs?
The fact that OData has an issue with refreshing many-to-many relationships is mentioned at the conclusion of this post, yet I can't even make one! http://msdn.microsoft.com/en-us/library/vstudio/bb896317(v=vs.100).aspx
I would appreciate any assistance in figuring out why I can't use EF6.0 and an OData client to construct a many-to-many relationship with an OData server.