实体框架中的 POCO 是什么?

我刚刚开始学习 POCO,但是我不能理解它的用法和优点。甚至下面的 StackOverflow 链接也没有帮到我。

与 POCO 的实体框架是什么

谁能举个简单的例子解释一下 POCO 的用法?

136520 次浏览

POCOs(Plain old CLR objects) are simply entities of your Domain. Normally when we use entity framework the entities are generated automatically for you. This is great but unfortunately these entities are interspersed with database access functionality which is clearly against the SOC (Separation of concern). POCOs are simple entities without any data access functionality but still gives the capabilities all EntityObject functionalities like

  • Lazy loading
  • Change tracking

Here is a good start for this

POCO Entity framework

You can also generate POCOs so easily from your existing Entity framework project using Code generators.

EF 5.X DbContext code generator