87

I just started learning POCO but I cannot understand the usage and advantage. Even the following link of StackOverflow did not help me.

what is Entity Framework with POCO

Can anybody explain the usage of POCO with a simple example?

sajadre
  • 1,141
  • 2
  • 15
  • 30
  • 5
    I think the best way for you to understand it is going through an example: http://pratapreddypilaka.blogspot.com.au/2011/12/entity-framework-40-poco.html – Jeremy Thompson Apr 18 '13 at 05:41
  • I'm not sure what answer you are expecting that wasn't already given in your link. If you still don't understand after reading those then perhaps, as Jeremy suggests, you need to learn by doing. – Ant P Apr 18 '13 at 05:51

1 Answers1

108

POCOs(Plain old CLR objects) are simply entities of your Domain. Normally when we use entity framework the entities are generated automatically for you. This is great but unfortunately these entities are interspersed with database access functionality which is clearly against the SOC (Separation of concern). POCOs are simple entities without any data access functionality but still gives the capabilities all EntityObject functionalities like

  • Lazy loading
  • Change tracking

Here is a good start for this

POCO Entity framework

You can also generate POCOs so easily from your existing Entity framework project using Code generators.

EF 5.X DbContext code generator

Sнаđошƒаӽ
  • 16,753
  • 12
  • 73
  • 90
Prabhu Murthy
  • 9,031
  • 5
  • 29
  • 36