Entity Framework on delete cascade

前端 未结 5 898
天涯浪人
天涯浪人 2020-12-10 03:31

I have problem with deleting related rows in Entity Framework 4.1. I have tables with relations

Book 1<--->* BookFormats

I have set the on delete cascade

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 04:09

    You can use RemoveRange :

    m.db.BookFormats.RemoveRange(originalBook.BookFormats);
    m.db.SaveChanges();
    

    But this is for EF 6.0

提交回复
热议问题