I created these classes in order to create a tree (user hold the root)
public class Node
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("Id")]
public Node Parent_Id { get; set; }
}
public class User
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("Id")]
public Node Root { get; set; }
}
but the entity framework (code first) doesnt save the parent_id (in the user class it save the "root" as expected)
when i created the tables manually (databese first) as it should be, the entity framework save the parent id as int and not "Node"
what can i do?
Parent_Idand not simplyParent? I haven't used EF in a while but maybe there is some convention for naming your properties?