添加实体模型时出现错误3007

问题描述:

将实体模型添加到解决方案中时出现错误3007。

I am getting an error 3007 when I add my entity model to my solution.

我找到了以下链接:

良好的爆炸力

简短答案

关于此错误:


错误1错误3007:映射
的问题从第89、94行开始的片段:
非主键列[Person_ID]
在两个片段中都映射到
不同的概念性侧面属性-
数据可能会不一致,因为
相应的概念性侧面
属性可以独立修改

Error 1 Error 3007: Problem in Mapping Fragments starting at lines 89, 94: Non-Primary-Key column(s) [Person_ID] are being mapped in both fragments to different conceptual side properties - data inconsistency is possible because the corresponding conceptual side properties can be independently modified.

他们的回答:我同意他们的结论,即只需删除标量属性Person_ID并保留导航属性,即可解决我的问题。但是,这不是很可扩展,因为我正在动态构建数据库并且我的实体经常更新。我不想每次更新实体时都要进行清理。

Their Answer: I agree with their conclusion that by simply deleting the Scalar Property Person_ID and leave the Navigation Property my problem is fixed. However this is not very scalable since I am dynamically building my database and my entity is updated very often. I dont want to have to go through and clean up my entity every time I update it.

我的问题:有没有办法解决通过更正EF建立实体的方式产生错误?还是有办法通过代码删除Scalar属性?也许我甚至忽略了一些选择。

My Question: Is there a way to fix the error by correcting the way EF builds the entity? Or is there a way to remove the Scalar Property through code? Perhaps there is even a few options that I am overlooking.

我对EF v1的体验与您相似。如果EDM生成不正确,并且您无法解决该问题,则必须手动编辑EDM。 EF v.Next(我相信是Entity Framework v4)将支持仅代码实体数据模型,而EDM设计器应该更好。一种或另一种改善应该使我们的生活更轻松。在那之前...

My experience with EF v1 is similar to yours. When the EDM is generated incorrectly and you can't work around the issue, you have to manually edit the EDM. EF v.Next (Entity Framework v4 I believe) will support "Code Only" Entity Data Models, and the EDM designer is supposed to be much better. One or the other improvement should make our lives easier. Until then...