Say I have the following tables:
Essence, EssenceSet, and Essence2EssenceSet where Essence2EssenceSet holds just the IDs of the 1st 2 tables to form the M:M relationship
You can create M:N relation in EF without retrieving objects as well:
using (var context = new MyContext())
{
var firstEntity = new FirstEntity { Id = firstId };
var secondEntity = new SecondEntity { Id = secondId; }
context.FirstEntities.Attach(firstEntity);
context.SecondEntities.Attach(secondEntity);
firstEntity.SecondEntities = new HashSet();
firstEntity.SecondEntities.Add(secondEntity);
context.SaveChanges();
}
Anyway exposing junction table as entity is possible but you will lose comfort of EF and fallback to SQL like approach: