0

嗨,我正在使用实体框架 4.3。

我有一个表“Notes”,其中NoteId是主键(数据类型是 int)。我通过使用存储过程为 NoteId 生成了这样的值..

 notes.NoteId = (int)dbContext.GeneratePrimaryKey("Notes");

当我将数据插入到表“ Notes ”中时,它会引发空值无法插入到 noteid 中。但是noteid是生成的。

谁能帮我解决这个问题....

4

1 回答 1

0

我猜你的映射期望主键是在数据库中自动生成的。在这种情况下,您的值将不会被使用。验证在您的 EDMX 中该NoteId属性已StoreGeneratedPattern设置为None

于 2012-03-17T11:05:04.673 回答