What is POCO in Entity Framework?

C#.NetEntity FrameworkPoco

C# Problem Overview


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

https://stackoverflow.com/questions/2672409/what-is-entity-framework-with-poco

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

C# Solutions


Solution 1 - C#

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1556433View Question on Stackoverflow
Solution 1 - C#Prabhu MurthyView Answer on Stackoverflow