Entity Framework 4.0 and POCO
One of the thing that annoyed me most in Entity Framework 1.0 was the lack of support for POCO. I like to use a specific vertical layer for entities, and I like those entities to have only properties and to be POCO to say it simply. The problem in EF 1.0 is that entities are forced to inherit from a class. I could also use the IPOCO interfaces but it was a lot of code for little benefit.
The great thing I love in EF 4.0 (even if it is a beta) is that I can generate the edmx file without generating the classes. So basically, I have a EDMX file containing all the XML stuff (conceptual model, physical model and mappings) and I create my classes that Object Services will use. That way, I can put real POCOs in my entity layer.
This is an entity that I can create and use with EF (and the corresponding EDMX) :
EF will manage the related entities the same way it does with generated entities. That means, you can also benefit from the lazy-loading or deferred-loading mecanism, and change tracking.
As a side note, EF 4.0 nows supports complex types (even in the designer).
The great thing I love in EF 4.0 (even if it is a beta) is that I can generate the edmx file without generating the classes. So basically, I have a EDMX file containing all the XML stuff (conceptual model, physical model and mappings) and I create my classes that Object Services will use. That way, I can put real POCOs in my entity layer.
This is an entity that I can create and use with EF (and the corresponding EDMX) :
public class Client
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Address Address { get; set; }
}
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Address Address { get; set; }
}
EF will manage the related entities the same way it does with generated entities. That means, you can also benefit from the lazy-loading or deferred-loading mecanism, and change tracking.
As a side note, EF 4.0 nows supports complex types (even in the designer).
Comments
Post a Comment