实体框架中的POCO是什么? [英] What is POCO in Entity Framework?

查看:160
本文介绍了实体框架中的POCO是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习POCO,但是不了解其使用和优势。即使以下的stackoverflow链接没有帮助我。

I just started learning POCO but cannot understand its use and advantage. Even following link of stackoverflow did not help me.

什么是使用POCO的实体框架

可以用简单的例子解释POCO的用法吗?

Can anybody explain the usage of POCO with a simple example?

推荐答案

POCO(简单的CLR对象)只是您的域的实体。通常当我们使用实体框架时,会为您自动生成实体。这是伟大的,但不幸的是,这些实体散布着数据库访问功能,这显然是针对SOC(分离关注)。 POCO是没有任何数据访问功能的简单实体,但仍然提供所有功能 EntityObject 功能,如

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实体框架

您还可以使用代码生成器从现有的实体框架项目轻松生成POCO。

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

EF 5.X DbContext代码生成器

这篇关于实体框架中的POCO是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆