且构网

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

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

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

对于那些像我一样在谷歌上搜索并最终来到这里的人,这就是您目前在 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