Entity Framework 4 & WCF Data Service: N:M mapping
- by JJO
I have three tables in my database: An A table, a B table, and a many-to-many ABMapping table. For simplicity, A and B are keyed with identity columns; ABMapping has just two columns: AId and BId.
I built an Entity Framework 4 model from this, and it did correctly identify the N:M mapping between A and B. I then built a WCF Data Service based on this EF model.
I'm trying to consume this WCF Data Service. Unfortunately, I can't figure out how to get a mapping between As and Bs to map back to the database. I've tried something like this:
A a = new A();
B b = new B();
a.Bs.Add(b);
connection.SaveChanges();
But this doesn't seem to have worked. Any clues? What am I missing?