无法检索关系的元数据信息

时间:2011-10-01 00:21:38

标签: c# .net entity-framework

我正在使用实体框架4.0。我也有工人实体。每次我尝试插入一个worker时 - 我在Context.SaveChanges();命令中得到一个异常:

The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: Metadata information for the relationship 'MyModel.FK_T_TRN_WORKER_VEHICLE_T_DRIVER' could not be retrieved. If mapping attributes are used, make sure that the EdmRelationshipAttribute for the relationship has been defined in the assembly.  When using convention-based mapping, metadata information for relationships between detached entities cannot be determined.
Parameter name: relationshipName

为了解决这个问题,我删除了FK_T_TRN_WORKER_VEHICLE_T_DRIVER关系,然后更新模型以再次加载此关系。
后来运行时 - 我得到了同样的例外,但与其他FK关系... 我必须删除该关系,然后再次加载它(更新模型)以修复异常,但是当再次运行时,我得到相同的异常,但与其他FK关系等等。

如果我不清楚,这就是我发生的事情:

1. I get an exception.
2. I delete the foreign key.
3. I update the model to load the foreign key.
4. I run the system.
5. I get step 1 but with other exception.

这个问题的原因是什么?我该怎么做呢?

0 个答案:

没有答案