The Code-First model:
public class Princess
{
public int Id { get; set; }
public virtual ICollection<Unicorn> Unicorns { get; set; }
}
public class Unicorn
{
public int Id { get; set; }
public virtual ICollection<Princess> Princesses { get; set; }
}
is it possible to remove an entity from the collection without load (eager or lazy) all the collection data?
var princess = context.Princesses.Where(x => x.Id == 1).Single();
var unicorn = context.Unicorns.Where(x => x.Id == 1).Single();
princes.Unicorns.remove(unicorn); //load all assigned unicorns
context.SaveChanges();
I guess the ExecuteSqlCommand should work. Other solution?
Use stubs. Off the top of my head (may require tweaks):