Reputation: 8606
I have read about POCO (Plain old CLR (or C#) object) here ,and confused about usage of it.
If i can go with Code First approach then weather i need to create .edmx file? Without that how can i use poco with code first approach?
Please correct me if i understood something wrong in this case!
Thanks.
Upvotes: 5
Views: 5020
Reputation: 364399
POCO in EF is an entity class which is not dependent on EF = it doesn't derive from EF specific class (EntityObject
) and it doesn't contain EF dependent code (including EF specific attributes).
Code first always uses POCO (in terms of EF) because you write the class yourselves and it doesn't need to be derived from any EF specific parent. The corner case is situation where you are using data annotations for mapping because some data annotations are available only in EntityFramework.dll assembly - using these annotations violates POCO because your entity classes will become dependent on EF assembly.
Upvotes: 6
Reputation: 16038
You don't need an edmx file with code first. Code first means, that you write your entity classes yourself and don't generate them via the edmx file.
See this blog entry for a good introduciton to code first with EF 4.2.
Upvotes: 2