EF:“ReferentialConstraint中的依赖属性映射到存储生成的列”,ID更改

时间:2016-09-14 04:16:44

标签: c# asp.net entity-framework

我发生了这个错误,因为标题说。我搜索谷歌并找不到答案,因为如果我使用sql插入,它没关系,当我使用ef添加时,它无法正常工作。查看下面,它是我的数据库架构。 enter image description here

当我尝试将某些东西添加到好桌子时,发生了错误。良好的流畅api似乎是这样的:

app.dll

因此,在我的数据库中“中心”表的位置是好的,有谁知道如何解决它?

1 个答案:

答案 0 :(得分:1)

It looks like one of your foreign key columns is set to be Database Generated. Check that GoodTypeId in Goods is not set as auto incremented Identity. Also check the same for GoodId in OrderItems and GoodId in HomePageProducts.