Introduction to POCO classes in Entity Framework

Leave a Comment

By default, when you use the Database First or Model First development approaches, the entity classes in your data model inherit from the EntityObject class, which provides them with Entity Framework functionality. This means that these classes technically aren't persistence ignorant and so don't conform fully to one of the requirements of domain-driven design.

All development approaches of the Entity Framework can also work with POCO (plain old CLR objects) classes, which essentially means that they are persistence-ignorant because they don't inherit from the EntityObject class. In this tutorial you will use POCO classes.


Here is an example of a simple POCO class that only contains properties and methods:
public class Product
{
public long Id { get; set; }
public string Name { get; set; }
public double Price { get; set; }
public int NumberInStock { get; set; }
public double CalculateValue()
{
return Price * NumberInStock;
}
}


Getting Started with Entity Framework Code First
Introduction to POCO classes in Entity Framework
Create First MVC application in Visual Studio 2010
Creating the Entity Framework Data Model in Visual Studio
Create classes for each entity using Entity Framework
Create the Database Context using Entity Framework
Setting the Connection String in MVC Asp.Net Application
Creating a Controller and Views in MVC application

0 comments:

Post a Comment