Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Entity Framework
1. When was Entity Framework Released?
1. The first version of Entity Framework 3.5 was released along with Visual
Studio 2008 SP1 and .NET 3.5 SP1.
2. The second version (also the currentversion) of Entity Framework i.e. 4.0
was released along with VS 2010 and .NET 4.0.
(Diagramtaken fromMSDN)
Before the release of Entity framework 3.5,thereweremany database
access technologies like DAO(Data Access Objects),RDO(RemoteData
Objects), then ADO (ActiveX Data Objects) and then finally ADO.NET.
Although with ADO.NETworking with the DataSet and DataReader has
served our data access needs but a developer needs to spend a lot of time
being concerned with the details of the schema, trying to keep up with
database schema changes and doing redundanttasks while interacting with
the database, over and over again.
What is Entity Framework?
1. The ADO.NETEntity Framework (EF) is an Object/Relational mapping (ORM)
framework and is a set of technologies in ADO.NET, for developing
applications that interacts with data.
2. 2. ADO.NET developer spends a lot of time keeping up with the database
changes whereas EF provides a mapping from the relational database
schema to the objects and offers an abstraction of ADO.NET.
3. So with EF, you can define Entity classes that are independent of a database
structure and then map them to the tables and associations of the
database.
4. Since we are now working with Entities which have their own schema, we
are shielded from the changes in the database. The object context keeps
tabs on the entities that are changed.
5. In simple words, with the Entity Framework, you are architecting, designing
and developing at a conceptual level. You are no more worried about the
‘specific details’ of communicating with the database and switching from
one relational database to the other is also possible with EF, without much
efforts.
6. The Entity Framework’sORMimplementation provides many more services
like change tracking, identity resolution, lazy loading, and query translation
so that developers can focus on their application-specific business logic
rather than the data access fundamentals.
To view more details about change tracking, identity resolution, lazy loading, and
query translation just visit the below link:
http://www.develop.com/entityframework4
7. Itbasically generates business objects and entities according to the
database tables and provides the mechanismfor:
Performing basic CRUD (Create, Read, Update, Delete) operations.
Easily managing "1 to 1", "1 to many", and "many to many"
relationships.
Ability to haveinheritance relationships between entities.
3. What is the role of ADO.NET now?
EF was not released with the intension to replace ADO.NET.
It is in fact an enhancement to ADO.NET and helps eliminate the gap
between the application and the database.
Behind the scene, EF uses ADO.NET classes, but the details are abstracted
from you.
EF provides a shift from Database-oriented (DataReader, DataSet) to
Model-oriented development.
So instead of focusing on a Database, a developer focuses on the Entity that
represents the Business Model of the application.
Is EF an alternative to ADO.NET?
the answer would be "yes and no".
Yes because the developer will not be writing ADO.NET methods and classes for
performing data operations and
NO because this model is actually written on top of ADO.NET, meaning under this
framework, we are still using ADO.NET.
4. The Detailed Folder/File structure of EF :
There are mainly 3 files in EF listed Below:
CSDL- Conceptual schema definition language.
SSDL - Storeschema definition language.
MSL - Mapping specification language.
These are XML-based languages that respectively describethe conceptual model,
storagemodel, and the mapping between these models.
In an Entity Framework application, model and mapping metadata are loaded
fromthree files with extensions .csdl, .ssdl, and .msl.
When are they generated?
The Entity Data Model Designer (Entity Designer) stores model and mapping
information in an .edmx file at design time. At build time the Entity Designer uses
the information in an .edmx file to create the .csdl, .ssdl, and .msl files that are
needed by the Entity Framework atruntime.
Cpecial EF Folders:
5. Where are they located?
By default, they included in the binary file of output under bin folder. You are not
able see the physicalfiles. But you can also output CSDL, SSDL, and MSL Files as
saparated files . Here is how to make this happen.
You will find these files at below location:
6. There are mainly three approaches to create .edmx in the project
1. DatabaseFirstApproach
2. Model First Approach
3. Code FirstApproach