Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use POCO in MVC application

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.

like image 849
Arun Rana Avatar asked Jan 11 '12 10:01

Arun Rana


1 Answers

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.

like image 174
Ladislav Mrnka Avatar answered Sep 24 '22 02:09

Ladislav Mrnka