Entity Framework 4 & WCF Data Service: N:M mapping

Posted by JJO on Stack Overflow See other posts from Stack Overflow or by JJO
Published on 2010-06-02T15:58:27Z Indexed on 2010/06/08 16:22 UTC
Read the original article Hit count: 150

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?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about many-to-many