I have the following entities:
public abstract class Meter
{
public int MeterId { get; set; }
public string EANNumber { get; set; }
public string MeterNumber { get; set; }
public abstract void AddReading(CounterReading reading);
}
public abstract class ElectricityMeter : Meter { }
public class SingleElectricityMeter : ElectricityMeter
{
private Counter _counter = new Counter();
public virtual Counter Counter
{
get { return _counter; }
set { _counter = value; }
}
public override void AddReading(CounterReading reading)
{
Counter.Readings.Add(reading);
}
}
public class Counter
{
public int CounterId { get; set; }
private ObservableCollection<CounterReading> _readings = new ObservableCollection<CounterReading>();
public virtual ObservableCollection<CounterReading> Readings
{
get { return _readings; }
set { _readings = value; }
}
[NotMapped]
public CounterReading CurrentReading
{
get
{
return Readings.MaxBy(m => m.Reading);
}
}
}
When I set the Counter relation in runtime, everything works perfect.
When I try to load the saved data, my Counter object isn't loaded (it's the default Counter, and not the one with the data from my database).
Is this still because I'm using inheritance in my Meter?
My database looks decent enough with foreign keys:

Edit
Retrieving other nested entities works without problem.
