Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the 'big' advantages to have Poco with ORM?

Tags:

c#

orm

One advantage that comes to my mind is, if you use Poco classes for Orm mapping, you can easily switch from one ORM to another, if both support Poco.

Having an ORM with no Poco support, e.g. mappings are done with attributes like the DataObjects.Net Orm, is not an issue for me, as also with Poco-supported Orms and theirs generated proxy entities, you have to be aware that entities are actually DAO objects bound to some context/session, e.g. serializing is a problem, etc..

like image 393
Bonefisher Avatar asked Apr 14 '10 08:04

Bonefisher


People also ask

What is Poco in ORM?

Introduction. POCO ActiveRecord is a simple and lightweight object-relational mapping (ORM) framework built on top of the POCO Data library.

What is Poco class in Entity Framework?

A POCO entity is a class that doesn't depend on any framework-specific base class. It is like any other normal . NET CLR class, which is why it is called "Plain Old CLR Objects". POCO entities are supported in both EF 6 and EF Core.

What is POCO database?

First Steps. POCO Data is POCO's database abstraction layer which allows users to easily send/retrieve data to/from various databases. Currently supported database connectors are SQLite, MySQL/MariaDB, PostgreSQL and ODBC (which covers SQL Server and other databases).


1 Answers

POCO it's all about loose coupling and testability.

So when you are doing POCO you can test your Domain Model (if your're doing DDD for example) in isolation. You don't have to bother about how it is persisted. You don't need to stub contexts/sessions to test your domain.

Another advantage is that there is less leaky abstractions. Because persistance concerns are not pushed to domain layer. So you are enforcing the SRP principle.

The third advantage I can see is that doing POCO your Domain Model is more evolutive and flexible. You can add new features easier than if it was coupled to the persistance.

I use POCO when I'm doing DDD for example, but for some kind of application you don't need to do DDD (if you're doing small data based applications) so the concerns are not the same.

Hope this helps

like image 139
Tomasz Jaskuλa Avatar answered Nov 01 '22 16:11

Tomasz Jaskuλa