Entity Framework - related ICollection materialized in HashSet

I am using EntityFramework POCO + proxies + lazy loading in my project. Today I was quite surprised to see that the Transaction class has an associated Rows collection materialized in a HashSet (instead of an EntityCollection ). I need an EntityCollection to track changes to the collection.

 public class Transaction { public virtual ICollection<TransactionRow> Rows { get; set; } } 

However, other feature classes have an assembly associated with them, materialized in the EntityCollection .

I load Transaction through ObjectQuery , so it should be in context. A proxy server for the object is also created.

Can anyone say how the Entity Framework decides whether to use a HashSet or EntityCollection? Why do some things become HashSets?

+6
hashset entity-framework entity-framework-4 poco
source share
1 answer

A change tracking proxy is created only when these two conditions are met:

  • The POCO class is public, not sealed, and not abstract.
  • All saved properties (with getter and setter) are marked as virtual
+2
source share

All Articles