C# 实体框架中的 POCO 是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16075245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is POCO in Entity Framework?
提问by
I just started learning POCO but cannot understand its use and advantage. Even following link of stackoverflow did not help me.
我刚开始学习 POCO,但无法理解它的用途和优势。即使遵循stackoverflow的链接也没有帮助我。
what is Entity Framework with POCO
Can anybody explain the usage of POCO with a simple example?
谁能用一个简单的例子来解释 POCO 的用法?
采纳答案by Prabhu Murthy
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 EntityObjectfunctionalities like
POCO(普通的旧 CLR 对象)只是域的实体。通常,当我们使用实体框架时,实体会自动为您生成。这很好,但不幸的是,这些实体散布着数据库访问功能,这显然违反了 SOC(关注分离)。POCO 是没有任何数据访问功能的简单实体,但仍提供所有EntityObject功能,如
- Lazy loading
- Change tracking
- 延迟加载
- 变更追踪
Here is a good start for this
这是一个好的开始
You can also generate POCOs so easily from your existing Entity framework project using Code generators.
您还可以使用代码生成器从现有的实体框架项目轻松生成 POCO。

