I have the following view
vw_Resources
-> ResourceId
-> Name
-> ReportsTo (maps to ResourceId)
and the class
public class Resource
{
public int ResourceId{get;set;}
public string Name{get;set;}
public Resource ReportsTo{get;set;}
}
and the DbContext
public class MyContext
{
public DbSet<Resource> Resources { get; set; }
}
How do I map the ReportsTo so that the DbContext returns a Resource object. I have to do this in the following method in the DbContext class using the ModelBinder
protected override void OnModelCreating(DbModelBuilder modelBuilder)
The following mapping worked