POCO which stands for "Plain Old CLR Objects" is an entity/class and doesn’t depend on any specific base class. It is like any other Dot net class you have seen before. These POCO entities (also known as persistence-ignorant objects) also support most of the same LINQ queries you use in you Data access layers for your business objects. POCO is a simple object to be used with a complicated, special object framework such as an ORM component. In other definition POCOs are entities of your domain, so When you use entity framework, these entities are generated for you. You can also use code generators to generate these entities. POCOS are just simple entities without any data access functionality but still gives the capabilities all EntityObject functionalities like Lazy loading and Change tracking.
Persistence ignorance means that, as much as possible, anything in your code operating at the business logic layer or higher knows nothing about the actual design of the database, what database engine you're running, or how or when objects get retrieved from or persisted to the database. The domain objects should be ignorant of persistence logic. For example, instead of calling Product.Save(), it's better to call Repository.Save(product). In this way, you get better separation of concerns and avoid exposing persistence semantics on your business objects. The Entity Framework enables you to use custom data classes together with your data model without making any modifications to the data classes themselves. This means that you can use "plain-old" CLR objects (POCO), such as existing domain objects, with your data model. Although these days most of the people like to go through the Code first approach and create their own POCO classes instead of create POCO entities after creating the database.
- POCO entities are not always needed to be hand-craft.
- Lazy loading works with POCO entities.
- Entity framework and Nhibernate both support for lazy loading of POCO
- POCO cannot use inheritance with your complex type classes
- complex types with POCO only supported Complex Type is class.