I have a issue with updating value on a foreign key which is inheriting from another class. I am working with detached object in Entity Framework, so I'm using graphdiff to handle it.
I've simplified the code to make it easier to read
Project class:
public class Project
{
public Guid Id { get; set; }
public virtual List<Activity> Activities { get; set; }
}
Activity class:
public class Activity
{
public Guid Id { get; set; }
public String Name { get; set; }
public virtual Company Company { get; set; }
}
SurfingActivity class:
public class SurfingActivity : Activity
{
public String Comment { get; set; }
public virtual Weather Weather { get; set; }
}
The update context using graphdiff:
public void UpdateActivity(Project project)
{
this.UpdateGraph(project, map => map
.OwnedCollection(p => p.Activities, with => with
.AssociatedEntity(a => a.Company)
)
);
}
I'm only able to associate the Company property in Activity but not the Weather of SurfingActivity. When I pass along values for SurfingActivity does Id, Name, Company and Comment get saved in the Activity table and the SurfingActivity table but not weather. Does anyone have any suggestion how to solve this without having to create a new property on Project that contains a list with surfingActivity