So I have two tables, A and B. Each table is set up like so:
A: ItemAId, ItemAProperty1, ItemAProperty2, etc.
B: ItemBId, ItemBProperty1, ItemBProperty2, etc.
I have a record in table A and a record in table B. These records are in no way related to each other.
I have a third table, C set up like so:
C: ItemAId, ItemBId
I want to make a new record in table C from existing records in tables A and B. C is not available using intellisense. Everywhere I've looked, the suggestion is to build an object from A that already exists, and object(s) from B that already exist, add B to A (or vice versa), then do an add... and because the objects already exist in the database, EF will just do an update and link the objects together in the intermediate table. (From Insert/Update Many to Many Entity Framework . How do I do it?) I.E.:
/**** Rough Psuedocode ****/
var a = context.First(a => a.Id == passedInAId);
var b = context.First(b => b.Id == passedInBId);
a.BProperty.Add(b);
context.Add(a);
context.SaveChanges()
However, in this case, the objects have no properties that relates them so this is not working.
I know I can write a stored proc to do this, but is it possible to do with EF?