Domanda

In this article says :

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. These POCO data classes (also known as persistence-ignorant objects), which are mapped to entities that are defined in a data model, support most of the same query, insert, update, and delete behaviors as entity types that are generated by the Entity Data Model tools.

POCO is a DTO with behavior.

So POCO is no same as entity? What the difference?

È stato utile?

Soluzione

Plain Old CLR Object (POCO) has the same meaning as Plain Old Java Object (POJO).

The term was coined while Rebecca Parsons, Josh MacKenzie and I were preparing for a talk at a conference in September 2000. In the talk we were pointing out the many benefits of encoding business logic into regular java objects rather than using Entity Beans. We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it's caught on very nicely.

by Martin Fowler

POCO is simply a regular object that has no references to any specific framework and does not follow their interfaces or restrictions. POCO classes are persistence ignorant objects that can be used with any ORM.

Entity is an object which has an identity and can be uniquely determined.

Entities represent domain model and domain logic. Usually they are designed as persistence ignorant POCO objects. But not every POCO object is an Entity. Value Objects are also designed as POCO objects and they are not Entities.

Altri suggerimenti

An entity usually requires a specific design in ORMs such as EF and NHibernate. Lazy loaded associations are usually virtual so a proxy can be created by the run time. The default public constructor is usually required. And so on.

Traditional entities are usually generated by the designer in EF. But in more recent versions classes can be designed with the required rules and mapped to the database.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top