1

这是我的桌子:

-- Original table schema
CREATE TABLE [SchoolYear] (
    [Start] datetime NOT NULL,
    [End] datetime NOT NULL,
    [Id] integer PRIMARY KEY ON CONFLICT ABORT AUTOINCREMENT NOT NULL
);

EF 设计器中的我的实体已将 StoredGeneratedPattern 设置为 Identity OR Compute,并且数据类型为 int64。

每次我插入第二个 SchoolYear 对象时,我都会收到此错误:

具有相同键的对象已在 ObjectStateManager 中...

4

1 回答 1

3

检查 autoincremented 属性的 StoreGeneratedPattern 属性是否在模型的 SSDL 部分中设置为“Identity”,而不是在 CSDL 中。
这是一个已知问题,生成代码时不考虑概念属性。

于 2010-07-16T07:45:01.677 回答