Every time I create a new data model with EF, I have to enter the TT file and substitute each occurrence of ICollection and the first occurrence of HashSet for ObservableCollection as well as the namespace Generic for ObjectModel.
The process is described on the internet (the bullet list right above "Lazy Loading" section) and seems to be as a hacky work-around for a shortcoming of a new technology, which with time should have been remedied and not needed.
Is it possible to automatically create observable collection or is the approach described the most efficient and generally applied?
I think customizing a .TT template for your need is an acceptable (or more: best) practice. The only question, Do this customizing process repeatedly/manually or create your own .TT and install it as Visual Studio Item Template. My vote goes to this second option, which is a little application of DRY.
However you need to prepare yourself to a drawback: When original .TT item templates will change (new version, etc) then you should apply those changes on your custom templates too. The easiest way to do this: diff, then choose the most efficient way: Replicate version changes on your custom template or reapply your customization changes on the new version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With