3

As you all know, in order to allow lazy loading and change tracking in entity framework, all the properties of the entity objects must be virtual.

My question is: since making the properties virtual is a requirement of entity framework, does it violate the principal of persistence ignorance and separation of concerns?

I understand that making the properties virtual doesn't couple my entities specifically to entity framework, but making the properties virtual is an imposition of entity framework and not necessarily of other framework/orm's.

If so, is there a way of avoiding making the properties virtual?

Thank you

areller
  • 4,800
  • 9
  • 29
  • 57
  • 1
    Could you expand you question to include why you think it might be a problem? – Matt Burland Sep 01 '15 at 15:30
  • This [blog post](http://blogs.msdn.com/b/dsimmons/archive/2007/06/02/persistence-ignorance-ok-i-think-i-get-it-now.aspx) might also be informative. – Matt Burland Sep 01 '15 at 15:32
  • 2
    [This answer](http://stackoverflow.com/a/1974805) addresses the persistence ignorance of NHibernate, but it's abstract enough it might help you. Basically, yes it's not persistence ignorant to require `virtual`s, but ignorance is a sliding scale. – 31eee384 Sep 01 '15 at 15:33
  • @MattBurland I edited my question, basically what i was trying to say is that making the properties virtual is an imposition of entity framework and although it doesn't limit me in anyway, it is something specific to entity framework. – areller Sep 01 '15 at 15:38

0 Answers0