ADO.NET实体数据模型(实体对象)

时间:2021-04-12 02:09:25

I have entity instance(north)

我有实体实例(北)

NorthdatabaseEntity north = new NorthdatabaseEntity()

The problem is that i don't have access to ObjectContext methods. I tried to call them with object "north" but i didn't found the method "AddObject" or any other from ObjectContext. I thought that any entity object has all methods from ObjectContext class.

问题是我无法访问ObjectContext方法。我试图用对象“north”调用它们,但我没有找到方法“AddObject”或ObjectContext中的任何其他方法。我认为任何实体对象都有ObjectContext类的所有方法。

Where is the problem here?

这里的问题在哪里?

1 个解决方案

#1


1  

ObjectContext and entities are different objects; you may use ObjectContext to add/modify/delete objects, but entities does not have direct access to ObjectContext.

ObjectContext和实体是不同的对象;您可以使用ObjectContext添加/修改/删除对象,但实体不能直接访问ObjectContext。

You need to create an instance of ObjectContext and perform your operations on itself, not on entities.

您需要创建ObjectContext的实例并对其自身执行操作,而不是对实体执行操作。

#1


1  

ObjectContext and entities are different objects; you may use ObjectContext to add/modify/delete objects, but entities does not have direct access to ObjectContext.

ObjectContext和实体是不同的对象;您可以使用ObjectContext添加/修改/删除对象,但实体不能直接访问ObjectContext。

You need to create an instance of ObjectContext and perform your operations on itself, not on entities.

您需要创建ObjectContext的实例并对其自身执行操作,而不是对实体执行操作。