I'm using DbChangeTracker in my c#/asp.net project (Visual Studio 2017, Entity Framework 6.4.4), which works fine. However, I've problems with tracking all changes in tables in combination of a link table.
Example: two classes, bread and topping and a link table goodCombination
class bread {
public string name;
public int tasteScore;
}
class topping {
public string name;
public bool containsLactose;
}
class goodCombination {
string breadName; //foreign key to field name of class bread
string toppingName; //foreign key to field name of class topping
}
In EF the class goodCombination isn't a seperate class but part of the two classes bread and topping:
class bread {
public string name;
public int tasteScore;
public virtual ICollection<topping> toppings
}
class topping {
public string name;
public bool containsLactose;
public virtual ICollection<bread> breads
}
My problem is: changes in bread.name and bread.tasteScore are trackable. Changes in bread.toppings are not trackable! That means:
var allChangedEntities = this.ChangeTracker.Entries().Where(c => c.Entity is IChangeTrackableObject && c.State != System.Data.Entity.EntityState.Unchanged).ToList();
results in an empty list, even when a goodCombination is added or changed.
My question is: how to track these changes?