Entity-framework – what is difference between a Model and an Entity

datamodelentityentity-frameworkmodelviewmodel

I am confused to understand what is the meaning of this words:

Entity, Model, DataModel, ViewModel

Can any body help me to understanding them please? Thank you all.

Best Solution

The definition of these terms is quite ambiguous. You will find different definitions at different places.

Entity: An entity represents a single instance of your domain object saved into the database as a record. It has some attributes that we represent as columns in our tables.

Model: A model typically represents a real world object that is related to the problem or domain space. In programming, we create classes to represent objects. These classes, known as models, have some properties and methods (defining objects behavior).

ViewModel: The term ViewModel originates from the MVVM (Model View ViewModel) design pattern. There are instances in which the data to be rendered by the view comes from two different objects. In such scenarios, we create a model class which consists of all properties required by the view. It’s not a domain model but a ViewModel because, a specific view uses it. Also, it doesn’t represent a real world object.

DataModel: In order to solve a problem, objects interact with each other. Some objects share a relationship among them and consequently, form a data model that represents the objects and the relationship between them.

In an application managing customer orders, for instance, if we have a customer and order object then these objects share a many to many relationship between them. The data model is eventually dependent on the way our objects interact with each other. In a database, we see the data model as a network of tables referring to some other tables.

To know more about object relationships visit my blog post: Basics of Object Relationships

For more details visit my blog post: Entity vs Model vs ViewModel vs DataModel