I’m using the EF4.1 DbContext code generation, which creates POCO entities like this:
public partial class Employee
{
public Employee()
{
this.Roles = new HashSet<Role>();
}
public System.Guid EmployeeGUID { get; set; }
public string EmployeeID { get; set; }
public string PIN { get; set; }
public string FullName { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string JobTitle { get; set; }
public string DepartmentDescription { get; set; }
public Nullable<System.DateTime> LatestHireDate { get; set; }
public string CompanyEmailAddress { get; set; }
public Nullable<System.Guid> SupervisorGUID { get; set; }
public string SupervisorFullName { get; set; }
public string SupervisorCompanyEmailAddress { get; set; }
public string JobCode { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
How is this accomplished?
Instead of serializing your DBContext entities, I would create DTOs (Data Transfer Object) that represents what really needs to be serialized. Then, I would use something like AutoMapper to map your DBContext entities to your DTOs.
Update: This is a bit out of date, but the author explains some of the great uses for AutoMapper.