Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法检索关系的元数据信息_C#_.net_Entity Framework - Fatal编程技术网

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

C# 无法检索关系的元数据信息,c#,.net,entity-framework,C#,.net,Entity Framework,我使用的是实体框架4.0。我也有工人实体。每次我试图插入一个worker时,我都会在Context.SaveChanges中得到一个异常;命令: 为了解决这个问题,我删除了FK_T_TRN_WORKER_VEHICLE_T_DRIVER关系,然后更新模型以再次加载此关系。 稍后运行时-我得到相同的异常,但与其他FK关系。。 我必须删除该关系,然后将其加载并再次更新模型以修复异常,但当再次运行时,我会得到与其他FK关系相同的异常,以此类推 如果我不清楚,这就是发生在我身上的事情: 1. I get

我使用的是实体框架4.0。我也有工人实体。每次我试图插入一个worker时,我都会在Context.SaveChanges中得到一个异常;命令:

为了解决这个问题,我删除了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.

这个问题的原因是什么?如何进行独家销售?

您是否删除了edmx中的所有实体并刷新了模型?就我而言,您使用的是数据库优先的方法,这意味着您可以基于数据库创建和更新edmx模型。您在哪里删除了外键约束?在数据库、存储模型还是在概念模型中?你没有使用Code First和EF 4.1?@eriawan:我没有删除实体,因为它有很多关系,是其他实体的超级类型。我刚刚删除了关系。@yonexbat:我删除了edmx文件中的外键—存储模型和概念模型—我不首先使用代码和ef 4.1。
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.