What is the POCO Entity Framework?

.net c# entity-framework poco

Question

What advantages does employing POCO offer? Persistence Ignorance is a term that I'm not familiar with. What does it mean? that save-related items cannot be exposed by the poco object? I'm having trouble understanding this POCO that's been getting a lot of attention.

What distinguishes POCO from EF-generated entities?

1
32
4/20/2010 3:50:28 AM

Accepted Answer

Depending on who you ask, POCO stands for "Plain Old C# Object" or "Plain Old CLR Object." When a framework or API claims to operate on POCOs, it signifies that you are not need to create your objects inherit from any particular base classes in order to establish your object model. In general, since they have fewer prerequisites to function properly, frameworks that operate with POCOs provide you more flexibility and control over the design and implementation of your classes.

As much as possible, nothing in your code that operates at the business logic layer or higher should be aware of the actual design of the database, the database engine you're using, or the manner in which objects are retrieved from or persisted to the database. This is known as "persistence ignorance." When it comes to the MEF, persistent ignorance is obtained by dealing with POCOs and running queries using LINQ (i.e., not requiring the user to create any SQL queries to retrieve the desired objects).

Although it's debatable, it's widely accepted that in most cases, domain objects (or business objects; either way, the POCOs indicated above) should be unaware of persistence logic. Specifically, rather than callingMyBusinessObject.Save() , you have a class called IOManager or IOAdapter, and you callManager.Save(MyBusinessObject) . By doing this, you may improve the separation of concerns by avoiding exposing persistent semantics on your business objects.

45
4/7/2014 6:49:59 AM

Popular Answer

Plain old CLR objects, or POCO.

Simple CLR (C# or VB) objects allow me to write my software entirely in C# or VB without having to bother with obscure database languages like

UPDATE MYTABLE SET MYFIELD1 = @MYPARAMETER1, MYFIELD2 = @MYPARAMETER2 BLAH BLAH

POCOs that are (indirectly) related to a database are EF Generated Entities.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow