Entity Framework + Many-To-Many Inserts + WCF Class Library
-
Friday, June 17, 2011 5:28 PM
EF does not include the junction table in the model when representing many-to-many relationships. I understand the logic behind this as objects can do this relationship thus; ObjectA can have a collection of ObjectB and vice versa whereas databases cannot. My example is:
Entity called EBR and Entity called Warning (in the databas the junction table is EBRWarning).
I can't figure out how to insert a record into the juction table. In the client-side intellisense, neither object has a property of the other.
The junction table itself is available i.e. EBRWarning exists as an object but there is no 'Context.Add' method as thre is for other tables that I marked as Editable.
All Replies
-
Friday, June 17, 2011 7:17 PM
Context.EBRWarnings.Add option is Available use it..
-
Saturday, June 18, 2011 12:38 AM
RIA Services doesn't support Many-To-Many without using http://m2m4ria.codeplex.com. The alternative is to add the linking table to the model. The easiest way to do that is to add an additional non-key field to the linking (aka junction) table before generating your model.
-
Monday, June 20, 2011 5:19 AM
Thanks.
I'd come across lots of suggestions on how this works but not this.
-
Tuesday, March 06, 2012 12:45 AM
Refer this article. It talks about how it insert record in junction table. Hope this is useful.
http://nileshhirapra.blogspot.in/2012/03/entity-framework-insert-operation-with.html

