Why is EF trying to insert NULL in id-column?

前端 未结 9 2131
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 00:43

I am writing my project using Entity Framework 4.0 (Model first). At the beginning of the project, I faced with this problem: I am trying to insert the filled object in the

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 01:06

    Have a look at this: https://stackoverflow.com/a/5338384/171703 - entity framework might be assuming that your CategoryId field is an identity and therefore passing null to the database expecting it to fill it for you.

提交回复
热议问题