实体框架中的实体是什么? [英] What's an entity in entity framework?

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

问题描述

在接下来的教程中,了解实体框架,他们不断提及实体。我经常看到它被用作数据库上下文类中的 dbsets<> 的同义词,但它的字面含义是什么?

In the tutorials im following for learning about the entity framework, they keep mentioning entities. I often see it gets used as a synonym for the dbsets<> in the database context class, but what's the literal meaning of it?

我已经知道实体框架如何工作,我只是不明白这个词的含义。

I already know how the entity framework works, I just dont understand the meaning of the word.

推荐答案

在实体框架中,一个实体在很大程度上等同于概念模型(或类模型中的,它被映射到商店模型)

In Entity Framework an entity is largely equivalent to a class in the conceptual model (or the class model, which is mapped to the store model).

在域模型中,一个实体是

In domain model terms an entity is


不是由它的属性定义的,而是由连续性和它的身份线程。

An object that is not defined by its attributes, but rather by a thread of continuity and its identity.

(来源:维基百科

对于一个对象的身份,而不是一个值对象,像一个 DateTime 或(也许)一个广告裙。一个客户是一个实体,因为它是由谁确定的。两个同名的客户仍然是两个客户。

That quite a mouthful for "an object with an identity", as opposed to a value object, like a DateTime or (maybe) an Address. A Customer is an entity, because it is identified by "who" he is. Two customers with the same name are still two customers.

所以实体可以松散地被定义为业务领域的事情。客户/用户和系统设计人员/开发人员以无所不在的语言谈论的事情。而在EF中,这些东西由课程代表。

So entities can loosely be defined as the "things" the business domain is about. The things both the customer/user and the system designer/developer talk about in ubiquitous language. And in EF those things are represented by classes.

所以它不是 DbSet DbSet 是一个提供实体对象的存储库。

So it's not the DbSet. The DbSet is a repository that provides entity objects.

我经常看到人们将实体称为模型。我不知道这个术语的起源(似乎经常发生这样的巧合),但我不认为这是正确的。这真的很混乱EF中的模型是商店模型或概念模型,因此它是实体的集合。模型也可以是包含任意数量实体的任意数量属性的视图模型。

I often see people referring to entities as models. I don't know the origin of this terminology (it seems to happen too often to be a coincidence), but I don't think it's correct. It's mostly confusing. The model in EF is either the store model or the conceptual model, so it's a collection of entities. A model can also be a view model that comprises any number of attributes of any number of entities.

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

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