这与 previous question 非常相似(并且可能是完全相同的问题)但我真的不明白答案,无法确定。
我在 Visual Studio RC1 中使用 Entity Framework 4 创建一个 azure 服务应用程序(因此它是 .Net 3.5)。我有一个包含很多模式的数据库,如下所示:
Thing ThingType
------------- --------------
Id : int Id : int
Type : int
其中 Thing.Type 引用了一个 ThingType。当 EF4 从数据库组装模型时,会生成一条错误消息:
Error 2016: Condition cannot be specified for Column member 'Type' because it is marked with a 'Computed' or 'Identity' StoreGeneratedPattern.
我不知道如何前进,但显然这是一种非常常见的情况。我非常有信心有人可以帮助我。
最佳答案
在 RC1 中存在一个错误,即外键关系不断被标记为 StoreGeneratedPattern="Identity"
。这可能会导致您在此处看到的问题,但我不能肯定地说,因为您的环境不同。查看您的 EDMX 文件,您应该只看到 StoreGeneratedPattern="Identity"Thing 和 ThingType 的 Id 字段,而不是 ThingThingType 关系。
Microsoft 已确认此错误已针对 RTM 修复,这很好,因为每次从数据库更新模型时它都会影响您!
关于entity-framework - EF4 0..1 关系导致错误 2016 : Condition cannot be specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2610016/