EF7 Fluent API: Self Referencing Tables
It appears as if EF7 uses all new Fluent API. Does anyone know where I might find more info? I'd like to implement self referencing tables with EF7.
public class Employee
{
public int EmployeeId //minus the gets and sets
public Employee Manager //maps to the manager's Employee
public int ManagerId //maps to the manager's Employee.EmployeeId
public string Name
public Employees
}
//EF7 Fluent API does not seem to support the following.. perhaps there is a translation? HasOptional(x => x.Manager) //new Fluent API property maybe?? .WithMany(x => x.Employees) //new Fluent API .OneToMany .HasForeignKey(x => x.ManagerId) //new Fluent API ForeighKey .WillCascadeOnDelete(false); //new Fluent API property maybe??
The EF 7 equivalent is
.Entity
Cascade on delete is not supported yet
The following are not resolving for me, I assume they are introduced in later builds of EF7 after "7.0.0-beta1", is that correct?
.HasOne(x => x.Manager) .WithMany(x => x.Employees)
Correct, they are currently in nightly builds. Here is some info on using the latest builds https://github.com/aspnet/EntityFramework/wiki/Getting-Started-with-Nightly-Builds.
@rowanmiller @AndriySvyryd
Alright, no problems with storing the data, but is there a way to retrieve a hierarchy of depth n?
#3241