Entity Framework 4.1中缺少DeleteObject方法 [英] DeleteObject method is missing in Entity Framework 4.1

查看:471
本文介绍了Entity Framework 4.1中缺少DeleteObject方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我疯狂。我收到的错误是,


对象不包含DeleteObject的定义。


这是我的代码行产生一个错误:

  ctx.Tanks.DeleteObject坦克); 

我尝试引用另一个对象从 edmx 文件,我的朋友创建,然后一切都很好, DeleteObject 存在。我不认为我错过任何参考在我的项目。



和项目本身包含edmx文件,我使用 DBContext

解决方案

code> DbContext
API定义 DbSet 不是 ObjectSet DbSet 有一个删除 code>方法不 DeleteObject 方法。您需要首先决定要使用哪个API。如果 ObjectContext DbContext


This is driving me crazy. I am getting error that

object doesn't contain definition for DeleteObject.

Here is my line of code that produces an error:

ctx.Tanks.DeleteObject(Tank);

I tried to reference another object from another edmx file that my friend has created and then everything is fine, DeleteObject exists. I don't think I miss any references in my project.

And project itself contains edmx file and I used DBContext to create POCOs.

Any ideas?

解决方案

The DbContext API defines DbSets not ObjectSets. DbSet has a Remove method not DeleteObject method. You need to first decide which API you are going to use. If it the ObjectContext or DbContext.

这篇关于Entity Framework 4.1中缺少DeleteObject方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆