views:

159

answers:

2

So I'm starting to look into EF and POCO.

From my understanding, the entity generated by EF is not pure POCO since it inherit from EntityObject.

But are they PI? It seem to me that they don't have any persistence awareness in them, or there is something in the EntityObject that makes them PI?

A: 

Entity Framework is persistence independent in that it is possible to write custom Entity Framework providers for alternate data stores. For example, here is a sample provider written for Oracle.

http://code.msdn.microsoft.com/EFOracleProvider

As for the POCO support, I believe the picture is much improved in Framework 4.0 where POCO's are supported. I might have this wrong though, since I am a little new to this my self.

Chris Taylor
+1  A: 

With C# 4.0 / .NET 4, the Entity Framework supports POCO's as entities and thus supports what is called Persistence Ignorance. In previous releases, this was not supported.

On the Switzerland Techdays site, you will find 2 Sessions on Entity Framework 4.0 with Jeff Derstadt, with video and slides coverage, in english:

Marcel
So Entity generated by the EF are Persistence Ignorance?
pdiddy
@pdiddy: No, not by default, but with EF 4.0 you could use PI entities. Watch the "Deep Dive" video to find out more.
Marcel
What makes the entity not PI?
pdiddy
Because, in .NET 3.5, it can not be a POCO. It must derive from EntityObject and have fancy Attributes like:[global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="MyModel", Name="MyEntity")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class MyEntity : global::System.Data.Objects.DataClasses.EntityObject
Marcel