I asked a very similar question earlier today, so you might get a bit of deja vu, but I’m afraid I can’t work this one out.
I have 3 MySql tables: Students, Classes and StudentsInClasses.
The Entity Framework translates these into two entities Student and Class, each linking to the other with a many-to-many navigation property (e.g. Student.Classes).
But there is no StudentsInClasses entity, so what’s the best way to call, using LINQ to Entities, the equivalent of SQL:
DELETE FROM StudentsInClasses;
I definitely want to avoid loading all Classes and their Students. Of course I could do it that way, but that would be horrendous because there are thousands of them and there should be no need.
Many thanks.
If you don’t like executing a store command like Paperjam suggested you could also create a stored procedure for this. That would nicely map to a static typed function on your ObjectContext.