原文:https://blog.csdn.net/weixin_40719943/article/details/106960166
四种方式删除
var club1 = context.Clubs.Single(x => x.Name == "Club1"); //方式1 context.Clubs.Remove(club1);
//方式2 context.Remove(club1); var club2 = context.Clubs.Single(x => x.Name == "Club2"); //方式3 删除多个 context.Clubs.RemoveRange(club1, club2); //方式3 删除多个 context.RemoveRange(club1, club2); //saveRange之后才会真正删除,返回被删除的个数 var count=context.SaveChanges();