I found a solution. It is possible to change type of all navigation properties which are collections. Text Template *.tt file for Model First auto-generated entities should be edited.
By default, EF5 generates navigation properties of HashSet
type:
If(edmProperty.ToEndMember.RelationshipMultiplicity = RelationshipMultiplicity.Many)
defaultValue = " = New HashSet(Of " & propertyType & ")"
propertyType = "ICollection(Of " & propertyType & ")"
End If
To change navigation properties type to ObservableCollection<T>
, two lines of *.tt code should be modified:
If(edmProperty.ToEndMember.RelationshipMultiplicity = RelationshipMultiplicity.Many)
defaultValue = " = New ObservableCollection(Of " & propertyType & ")"
propertyType = "ObservableCollection(Of " & propertyType & ")"
End If
Afterwards, entity classes should be regenerated automatically.