Skip to main content

What is POCO


Plain Old C# Object

Just a normal class, no attributes describing infrastructure concerns or other responsibilities that your domain objects shouldn't have.

EDIT - as other answers have stated, it is technically Plain Old CLR Object but I, like David Arno comments, prefer " Plain Old Class Object" to avoid ties to specific languages or technologies.

TO CLARIFY: In other words, they don’t derive from some special base class, nor do they return any special types for their properties.

An Example POCO

Below is an example Plain Old C# Object for a Product.

public class Product
public Product(int id)
Id = id;

private Product()
// required for EF

public int Id { get; private set; }
// other properties and methods

This Product class is a POCO because it has no dependencies on third-party frameworks for behavior, especially persistence behavior. It doesn't require a base class, especially a base class in another library. It doesn't have any tight coupling to static helpers. It can be instantiated anywhere without difficulty. It is much more persistence ignorant than the previous example, but it's not entirely ignorant of persistence, since it has an otherwise useless private constructor declaration. As you can see from the comment, that private parameterless constructor is only there because Entity Framework needs it to instantiate the class when it is reading it from persistence.