Self referencing / parent-child relationship in Entity Framework

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)