【发布时间】:2012-12-13 09:57:03
【问题描述】:
我在 VS2012 中使用 EF5,我尝试使用 ExecuteStoreCommand 删除某个表的所有数据,
像这样:
ctx.ExecuteStoreCommand("TRUNCATE TABLE [" + tableName + "]");
但问题是 EF 告诉我,找不到方法 ExecuteStoreCommand。我不明白为什么?
你能告诉我为什么吗?或者给我一个高效的解决方案删除表的所有数据。
【问题讨论】:
-
@tomfanning,这取决于他使用的是 ObjectContext 还是 DbContext
-
正确。 EF5/6 默认是 DbContext (POCO),除非你强制转换它们。
标签: c# entity-framework visual-studio-2012 entity-framework-5