In this article, I will provide introduction about entity framework. Before knowing about Entity framework, first let’s see what is ORM framework.
What is ORM framework?
ORM stands for Object relational mapping. The ORM framework allows you map object models of C# classes to relational databases.
ORM framework is useful to maintain databases in the application and saves a lot of time for the developer thus increases developer productivity. Key points of ORM framework:
- ORM framework can create classes based on database tables.
- It can create database tables based on class models.
- It helps you connect databases and executing SQL queries.
What is Entity Framework?
Entity framework is an ORM (Object relational mapping) framework. This framework is written on the top of ADO.Net, which is part of .NET framework. So, internally entity framework uses ADO.Net.
Entity framework generates model objects and entities based on database tables and vice versa. You can easily add relationships (like 1 to1 or 1 to many) between different entities. It allows you to perform basic CRUD (create, Read, Update and Delete) operations over the database tables.
- Less code- Less management: Entity framework reduces the total code to write as compared with ADO.Net, thus increases productivity.
- All the data access related logic can be written in C#. You can also specify relationships between entities in the code only. So maintaining the databases becomes easy for the developers.
- The database tables and relationships can be seen in the designers integrated to visual studio. It simplifies the mapping process.
- Entity framework supports LINQ for queries.
Entity Framework Models
Conceptual model includes model classes and relationship between different entities. Conceptual schema definition language (CSDL) defines the conceptual model.
Storage model describes the database description. It is also called the logical model. It includes tables, stored procedures, different keys (primary key and foreign key) and relationships between tables. Storage schema definition language (SCDL) defines the storage model.
Mapping model implements the relation between conceptual model and storage model. This is the real magic of entity framework. How a class is mapped to a database table and vice versa; these entire things are taken care by mapping model. Mapping specification language (MSL) defines the mapping between conceptual model and storage model.
This Framework allows you to create entity model by following approaches:
- Code First
- Database First
- Model First
I will explain details about these three approaches in next articles.
That’s it for this article. Please post your comments for queries and feedback. Thanks for reading.
Latest posts by Gyanendu Shekhar (see all)
- Create fake shadow using blob shadow projector: Unity tutorial - October 2, 2018
- Using Reflection Probe: Unity Tutorial - October 1, 2018
- Difference Between Material and Shared Material: Unity Tutorial - September 23, 2018