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
You must define the ParentId in the category class as nullable to use it as the foreign key property for an optional relationship:
ParentId
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.
int
null
NULL