Self referencing / parent-child relationship in Entity Framework

前端 未结 1 1951
醉话见心
醉话见心 2020-12-05 02:29

I read quite a number of posts of programmers that run into the Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign

相关标签:
1条回答
  • 2020-12-05 03:12

    You must define the ParentId in the category class as nullable to use it as the foreign key property for an optional relationship:

    public int? ParentId { get; set; }
    

    An int property cannot take the value null and therefore cannot represent a NULL as value in a database column.

    0 讨论(0)
提交回复
热议问题