How do I configure Entity Framework using fluent configuration to behave the same way that I would do this with attributes:
public class Product
{
public int? ParentId { get; set; }
[ForeignKey("ParentId")]
public virtual Product Parent { get; set; }
}
Supposing that you want to create a self referencing entity, I assume that you have a
Product
class like this:In the context, you need to implement the
OnModelCreating
method in order to configure the self reference.