views:

224

answers:

2

Is there a way to delete an entity by its EntityKey witout loading it?

+1  A: 

The link Tamir has works, but it uses an approach that the Entity Framework team no longer recommends.

Check out this tip which is closer to the right way to do it. And also covers the gotchas in more depth. (Dislaimer: I would say that I wrote the tip!)

Hope this helps

Alex

Program Manager Entity Framework Team.

Alex James
I guess i qualify the 'out of luck' part, this fact that i have to provide parent PKs is really unncessarry it should be fixed, for my opinion it's just a bug.
Shimmy
Most people agree with you and that is why the next version of the EF (starting with Beta2) introduces something called FK associations: http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx
Alex James