EF4 0..1 关系导致错误 2016:无法指定条件
这与上一个问题非常相似(并且可能是完全相同的问题)但我真的不太理解答案,无法确定。
我正在 Visual Studio RC1 中使用 Entity Framework 4 创建一个 azure 服务应用程序(因此它是 .Net 3.5)。我有一个包含很多模式的数据库,如下所示:
Thing ThingType
------------- --------------
Id : int Id : int
Type : int
其中 Thing.Type 引用 ThingType。当 EF4 从数据库组装模型时,会生成一个错误,内容如下:
错误 2016:无法为列成员“类型”指定条件,因为它标有“计算”或“标识”StoreGeneratePattern。
我不知道如何继续前进,但显然这是一个非常常见的情况。我非常有信心有人可以帮助我。
This is very similar to a previous question (and may be the exact same question) but I really didn't understand the answers enough to be able to tell for sure.
I am using Entity Framework 4 in Visual Studio RC1 to create an azure service app (so it is .Net 3.5). I have a database with a lot of patterns like the following:
Thing ThingType
------------- --------------
Id : int Id : int
Type : int
where Thing.Type is referencing a ThingType. When EF4 assembles the model from the database, an error is generated which reads:
Error 2016: Condition cannot be specified for Column member 'Type' because it is marked with a 'Computed' or 'Identity' StoreGeneratedPattern.
I'm at a loss as to how to move forward, but obviously this is a very common scenario. I feel very confident that somebody can help me out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 RC1 中,存在一个错误,即外来密钥关系不断被标记为
StoreGeneratePattern="Identity"
。这可能会导致您在这里看到的问题,但我不能肯定地说,因为您的环境不同。查看您的 EDMX 文件,您应该仅在 Thing 和 ThingType 的 Id 字段中看到 StoreGeneeratedPattern="Identity",而不是在 ThingThingType 关系上看到。另请参阅http://blog.abodit.com/2010 /03/system-data-updateexception-a-value-shared-across-entities-or-associations-is-generate-in-multiple-location-check-that-mapping-does-not-split-an -entitykey-to-multiple-store- generated-columns/
Microsoft 已确认 RTM 已修复此错误,这很好,因为每次从数据库更新模型时它都会影响您!
In RC1 there is a bug where the foregin key relationships keep getting marked as
StoreGeneratedPattern="Identity"
. This may be causing the issue you are seeing here but I cannot say for sure since your environment is different. Take a look at your EDMX file, you should see the StoreGeneratedPattern="Identity" only the Id field for Thing and ThingType and not on the ThingThingType relationship.See also http://blog.abodit.com/2010/03/system-data-updateexception-a-value-shared-across-entities-or-associations-is-generated-in-more-than-one-location-check-that-mapping-does-not-split-an-entitykey-to-multiple-store-generated-columns/
Microsoft has confirmed that this bug is fixed for RTM which is good since it affects you every time you update the model from the database!