且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架。删除表中的所有行

更新时间:2023-02-07 09:10:26

有关那些谷歌搜索这一点,并在这里结束了像我这样的,这是你目前如何做到这一点的EF5和EF6:

For those that are googling this and ended up here like me, this is how you currently do it in EF5 and EF6:

context.Database.ExecuteSqlCommand("TRUNCATE TABLE [TableName]");

假设上下文是 System.Data.Entity.DbContext