What is POCO Entity Framework ? [Resolved]

Posted by Kumarkrishna184 under ASP.NET MVC on 3/9/2016 | Points: 10 | Views : 1790 | Status : [Member] | Replies : 2
What is POCO Entity Framework ?Why do we use it?

Thanks and Regards,
Krishna Kumar



Responses

Posted by: Rajnilari2015 on: 3/10/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Kumarkrishna184 Sir,

POCO stands for Plain Old CLR Object or Plain Old C# Object.Precisely it is the Business Object.
It has data, validation (implemented by Data Annotation), and business/domain logic imbibed into it.However, it is persistence ignorant which means it cannot have the save operations (like insert/update/delete)

For example, let's as we have a RateOfInterestMaster POCO Domain Model (picked up from the recent project) as

public class CreateRateOfInterestMaster : FlexCommand

{
public CreateRateOfInterestMaster();

[StringLength(32)]
[RegularExpression("^([a-zA-Z0-9]{32}+)$", ErrorMessage = "Invalid Id")]
[Required]
public string Id { get; set; }

public string LoggedInUserId { get; set; }

[Required]
[StringLength(32)]

public string ProductId { get; set; }
[Required]
public decimal RateOfInterest { get; set; }

[Required]
[StringLength(32)]
public string SubProductId { get; set; }

}


More information: https://msdn.microsoft.com/library/dd456872(v=vs.100).aspx

Hope this helps

Please ask us in case of any doubt.

--
Thanks & Regards,
RNA Team

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Professionaluser on: 3/10/2016 [Member] [MVP] Bronze | Points: 25

Up
0
Down
POCOS(Plain old CLR objects) are simply entities of your Domain.Normally when we use entity framework the entities are generated automatically for you.This is great but unfortunately these entities are interspersed with database access functionality which is clearly against the SOC(Separation of concern).POCOS are simple entities without any data access functionality but still gives the capabilities all EntityObject functionalities like

Lazy loading
Change tracking
Here is a good start for this

http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://www.c-sharpcorner.com/UploadFile/5d065a/poco-classes-in-entity-framework/
http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx

You can also generate POCOS so easily from your existing Entity framework project using Code generators

when to use:
http://www.vkinfotek.com/poco/poco-vs-entity-framework-generated-classes.html
http://rlacovara.blogspot.in/2009/03/what-is-difference-between-dto-and-poco.html

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response