简体   繁体   English

删除数据库表中的行

[英]Deleting Rows in a Database Table

What's the easiest way to delete rows in a database table using Entity Framework 6? 使用Entity Framework 6删除数据库表中的行的最简单方法是什么?

I just pulled down EF6 via NuGet and have been able to successfully query rows from the DB. 我刚刚通过NuGet下拉了EF6,并且已经能够从数据库成功查询行。 However, I do not seem to have access to the context.<entity>.Delete() or context.<entity>.DeleteObject() methods, which are most often shown as examples online. 但是,我似乎无法访问context.<entity>.Delete()context.<entity>.DeleteObject()方法,这些方法在网上经常作为示例显示。

Got it working. 得到它的工作。

var query = <linq query>;

context.<entity>.RemoveRange(query);
context.SaveChanges();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM