SlideShare a Scribd company logo
ENTITY FRAMEWORK
Mr. Hasan Baloch
Mr. Jibran Rasheed Khan
Mr. Sehan Ahmed Farooqui
OUTLINE
• Introduction to Entity Framework (EF)
• Architecture
• What’s new!
• Different approaches to work with
• Choosing right work model
• Pictorial Tour to each model
• Features & Advantages
• Question & Answer
WHAT IS ENTITY FRAMEWORK???
• EF is a data access framework from Microsoft that helps to bridge the
gap between data structures and objects in your applications.
• It is an ORM framework.
• Enhancement to ADO.NET that gives automated mechanism for accessing
& storing in the database.
• Microsoft’s latest and recommended way for data access for .NET
applications.
ENTITY FRAMEWORK ARCHITECTURE
• EDM, Consists of Conceptual model, Mapping and Storage model.
• LINQ to Entities, Used to write queries against the object
model.
• Entity SQL, like L2E, but little more difficult.
• Object Service, Responsible for materialization.
• ECDP, Responsible to convert L2E or Entity SQL queries into a SQL
query.
• ADO.net, Communicates with the database using standard ADO
What’s new in EF 5
• Become Open Source
• Enum Support
• Spatial Data Types using DbGeography and DbGeometry classes.
• Table-Valued functions support
• Performance Enhancements
• Designer Improvement
• Better Query Performance
• Code First to add new tables to existing Db
ENTITY FRAMEWORK APPROACHES
DATABASE FIRST
Model the database artifacts
(tables, views, primary keys,
foreign keys, etc.)
Allows you to use legacy database
in your ORM application
Low level control over the
database
Entity Data Model can be updated
whenever database schema
changes.
Database-first approach supports
stored procedure, view, etc.
MODEL FIRST
Creating a model using the Entity
Framework designer tools
Designer can generate DDL
statements to create the database
An easy-to-use UI allows quickly
create new entities
Separation of code and database in
a declarative format
Dropping and re-creating the
database is not a choice
This uses an .EDMX file to store
model and mapping information.
CODE FIRST
The primary focus is getting the
code and logic
Define entity model with classes
and mappings in code..
Entity Framework create (and
recreate) the database for you.
Does not use Entity Framework
visual design tool, neither to design
entities
There is no XML file – no EDMX file –
to represent model and storage
schemas
CHOOSING
RIGHT WORK
MODEL
DATABASE FIRST
PICTORIAL TOUR
HOW TOs
The steps involved in this example are as follows:
Create the new SQL Server database
Create the database objects
Create a new C# Class Library Project in Visual Studio 2012 Solution
Add a new ADO.NET Entity Data Model to project
Create a new Database Connection
Import the database objects into the EDM
Modify the EDM to accommodate the scalar-valued functions
01
02
03
04 05
06
07 08
09
12
11
10
MODEL FIRST
PICTORIAL TOUR
HOW TOs
The steps involved in this example are as follows:
Creating the model
Creating entities in the .edmx
Editing entity properties
Applying relationships to the entities
 Name DatabaseSchema
Generating the database from the model
01 03
02
06
05
04
090807
10
11
12
1514
13
16 17 18
19 20 21
CODE FIRST
PICTORIAL TOUR
HOW TOs
The steps involved in this example are as follows:
Create a new Class Library
Create POCO (Plain Old CLR Object) classes
Add data annotations to the POCO classes.
Create enum classes (if required)
Add Entity Framework to the Solution
Add a DbContext class
Add ‘Code First Migrations’
Updates the database (if needed/made changes)
01 02
0304
04 05
06
07
FEATURES
• Works with a variety of database servers (including Microsoft SQL server, oracle,
and DB2)
• Rich mapping engine handle real-world database and work with stored procedure
• Generates strongly-typed entity objects that can be customized beyond 1-1
mapping
• Generates mapping/plumbing code
• Translates LINQ queries to database queries
• Materializes objects from data store calls
• Tracks changes, generating updates/inserts
Advantages
• Reduced development time
• Developers can work more application-centric
• Free from hard-coded dependencies on a particular data engine
• Mappings can be change without changing the application code
• L2Eprovides validation for writing queries against a conceptual model
• Integrates with all the .NET application programming models
• Worked well with ASP.NET, WPF, WCF, and WCF Data Services
Question & Answer
“A wise man can learn more from a foolish question than a fool can
learn from a wise answer.”
Bruce Lee
THANK YOU
Have Great Time
Ad

Recommended

PPTX
Getting started with entity framework
Lushanthan Sivaneasharajah
 
PPTX
Entity framework code first
Confiz
 
PPTX
Ado.Net Tutorial
prabhu rajendran
 
PPTX
android sqlite
Deepa Rani
 
PDF
Spring MVC Framework
Hùng Nguyễn Huy
 
PPTX
Angularjs PPT
Amit Baghel
 
PPT
3 Tier Architecture
Webx
 
PPT
XML and DTD
Jussi Pohjolainen
 
PPT
DOT Net overview
chandrasekhardesireddi
 
PPT
ADO .Net
DrSonali Vyas
 
PPTX
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
PPTX
Ooad unit – 1 introduction
Babeetha Muruganantham
 
PPTX
Ef code first
ZealousysDev
 
PPT
1 - Introduction to PL/SQL
rehaniltifat
 
PPTX
Strings in Java
Abhilash Nair
 
PPTX
Spring Framework
tola99
 
PPT
C# Exceptions Handling
sharqiyem
 
PPTX
Sql(structured query language)
Ishucs
 
PPTX
Java - Generic programming
Riccardo Cardin
 
PPT
C#.NET
gurchet
 
PPT
Jdbc ppt
Vikas Jagtap
 
PPTX
Object Oriented Design
DivyaSure
 
PPTX
Windows form application - C# Training
Moutasm Tamimi
 
PPTX
LINQ in C#
Basant Medhat
 
PPT
Software architecture design ppt
farazimlak
 
PPT
Sql Tutorials
Priyabrat Kar
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPTX
COLLECTIONS.pptx
SruthyPJ
 
PPT
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
PPTX
Entity Framework Database and Code First
James Johnson
 

More Related Content

What's hot (20)

PPT
DOT Net overview
chandrasekhardesireddi
 
PPT
ADO .Net
DrSonali Vyas
 
PPTX
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
PPTX
Ooad unit – 1 introduction
Babeetha Muruganantham
 
PPTX
Ef code first
ZealousysDev
 
PPT
1 - Introduction to PL/SQL
rehaniltifat
 
PPTX
Strings in Java
Abhilash Nair
 
PPTX
Spring Framework
tola99
 
PPT
C# Exceptions Handling
sharqiyem
 
PPTX
Sql(structured query language)
Ishucs
 
PPTX
Java - Generic programming
Riccardo Cardin
 
PPT
C#.NET
gurchet
 
PPT
Jdbc ppt
Vikas Jagtap
 
PPTX
Object Oriented Design
DivyaSure
 
PPTX
Windows form application - C# Training
Moutasm Tamimi
 
PPTX
LINQ in C#
Basant Medhat
 
PPT
Software architecture design ppt
farazimlak
 
PPT
Sql Tutorials
Priyabrat Kar
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPTX
COLLECTIONS.pptx
SruthyPJ
 
DOT Net overview
chandrasekhardesireddi
 
ADO .Net
DrSonali Vyas
 
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Ooad unit – 1 introduction
Babeetha Muruganantham
 
Ef code first
ZealousysDev
 
1 - Introduction to PL/SQL
rehaniltifat
 
Strings in Java
Abhilash Nair
 
Spring Framework
tola99
 
C# Exceptions Handling
sharqiyem
 
Sql(structured query language)
Ishucs
 
Java - Generic programming
Riccardo Cardin
 
C#.NET
gurchet
 
Jdbc ppt
Vikas Jagtap
 
Object Oriented Design
DivyaSure
 
Windows form application - C# Training
Moutasm Tamimi
 
LINQ in C#
Basant Medhat
 
Software architecture design ppt
farazimlak
 
Sql Tutorials
Priyabrat Kar
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
COLLECTIONS.pptx
SruthyPJ
 

Viewers also liked (17)

PPT
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
PPTX
Entity Framework Database and Code First
James Johnson
 
PPTX
Entity Framework - Entity Data Model (edm)
Eyal Vardi
 
PPTX
Beyond Gamification: designing the player journey
Amy Jo Kim
 
PPTX
.net framework from 1.0 -> 4.0
ligaoren
 
PPTX
Deep-dive building solutions on the SharePoint Framework
Waldek Mastykarz
 
PPTX
Introducing Entity Framework 4.0
Bishoy Demian
 
PPT
For Beginers - ADO.Net
Snehal Harawande
 
PPT
Introduction to ADO.NET
rchakra
 
PPT
.NET Framework Overview
Doncho Minkov
 
PDF
Data modelling 101
Christopher Bradley
 
PPTX
A Comparison of .NET Framework vs. Java Virtual Machine
Abdelrahman Hosny
 
ZIP
Beautiful Mind: iPhone Anatomy & Architecture
Bess Ho
 
PPTX
Евгений Напрягло ".NET Framework Hosting API Overview"
Fwdays
 
PPSX
Introduction to .net framework
Arun Prasad
 
PPTX
Entity Framework
vrluckyin
 
PPTX
Components of .NET Framework
Roshith S Pai
 
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
Entity Framework Database and Code First
James Johnson
 
Entity Framework - Entity Data Model (edm)
Eyal Vardi
 
Beyond Gamification: designing the player journey
Amy Jo Kim
 
.net framework from 1.0 -> 4.0
ligaoren
 
Deep-dive building solutions on the SharePoint Framework
Waldek Mastykarz
 
Introducing Entity Framework 4.0
Bishoy Demian
 
For Beginers - ADO.Net
Snehal Harawande
 
Introduction to ADO.NET
rchakra
 
.NET Framework Overview
Doncho Minkov
 
Data modelling 101
Christopher Bradley
 
A Comparison of .NET Framework vs. Java Virtual Machine
Abdelrahman Hosny
 
Beautiful Mind: iPhone Anatomy & Architecture
Bess Ho
 
Евгений Напрягло ".NET Framework Hosting API Overview"
Fwdays
 
Introduction to .net framework
Arun Prasad
 
Entity Framework
vrluckyin
 
Components of .NET Framework
Roshith S Pai
 
Ad

Similar to Learn Entity Framework in a day with Code First, Model First and Database First (20)

PDF
70487.pdf
Karen Benoit
 
PPTX
Ef overview
Uday Shankar
 
PPTX
Microsoft Entity Framework
Mahmoud Tolba
 
PPTX
Entity framework introduction sesion-1
Usama Nada
 
PPTX
Entity framework
Mehdi jannati
 
PPTX
Entity Framework Core 1.0
Senthil Kumar
 
PPT
Entity Framework Core (EF Core) Power Point Slide Show
hammadali341730
 
PPTX
05 entity framework
Bat Programmer
 
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
PPTX
Entity Framework 4
Stefano Paluello
 
PPTX
Be04 introduction to ef 6.0
DotNetCampus
 
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
PPTX
Entity Framework Overview
Eyal Vardi
 
PDF
Entity Framework Interview Questions PDF By ScholarHat
Scholarhat
 
PPT
Entity frameworks101
Rich Helton
 
PPTX
Building N Tier Applications With Entity Framework Services 2010
David McCarter
 
PPTX
Entity Core with Core Microservices.pptx
Knoldus Inc.
 
PPTX
MVC and Entity Framework 4
James Johnson
 
PPTX
Microsoft Data Access Technologies
David Chou
 
PPTX
Data virtualization, Data Federation & IaaS with Jboss Teiid
Anil Allewar
 
70487.pdf
Karen Benoit
 
Ef overview
Uday Shankar
 
Microsoft Entity Framework
Mahmoud Tolba
 
Entity framework introduction sesion-1
Usama Nada
 
Entity framework
Mehdi jannati
 
Entity Framework Core 1.0
Senthil Kumar
 
Entity Framework Core (EF Core) Power Point Slide Show
hammadali341730
 
05 entity framework
Bat Programmer
 
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Entity Framework 4
Stefano Paluello
 
Be04 introduction to ef 6.0
DotNetCampus
 
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Entity Framework Overview
Eyal Vardi
 
Entity Framework Interview Questions PDF By ScholarHat
Scholarhat
 
Entity frameworks101
Rich Helton
 
Building N Tier Applications With Entity Framework Services 2010
David McCarter
 
Entity Core with Core Microservices.pptx
Knoldus Inc.
 
MVC and Entity Framework 4
James Johnson
 
Microsoft Data Access Technologies
David Chou
 
Data virtualization, Data Federation & IaaS with Jboss Teiid
Anil Allewar
 
Ad

Recently uploaded (20)

PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
PPTX
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PDF
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
PDF
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
PDF
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
PDF
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PDF
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
 
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
PPTX
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
PDF
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
PDF
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
DOCX
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 

Learn Entity Framework in a day with Code First, Model First and Database First

  • 1. ENTITY FRAMEWORK Mr. Hasan Baloch Mr. Jibran Rasheed Khan Mr. Sehan Ahmed Farooqui
  • 2. OUTLINE • Introduction to Entity Framework (EF) • Architecture • What’s new! • Different approaches to work with • Choosing right work model • Pictorial Tour to each model • Features & Advantages • Question & Answer
  • 3. WHAT IS ENTITY FRAMEWORK??? • EF is a data access framework from Microsoft that helps to bridge the gap between data structures and objects in your applications. • It is an ORM framework. • Enhancement to ADO.NET that gives automated mechanism for accessing & storing in the database. • Microsoft’s latest and recommended way for data access for .NET applications.
  • 4. ENTITY FRAMEWORK ARCHITECTURE • EDM, Consists of Conceptual model, Mapping and Storage model. • LINQ to Entities, Used to write queries against the object model. • Entity SQL, like L2E, but little more difficult. • Object Service, Responsible for materialization. • ECDP, Responsible to convert L2E or Entity SQL queries into a SQL query. • ADO.net, Communicates with the database using standard ADO
  • 5. What’s new in EF 5 • Become Open Source • Enum Support • Spatial Data Types using DbGeography and DbGeometry classes. • Table-Valued functions support • Performance Enhancements • Designer Improvement • Better Query Performance • Code First to add new tables to existing Db
  • 6. ENTITY FRAMEWORK APPROACHES DATABASE FIRST Model the database artifacts (tables, views, primary keys, foreign keys, etc.) Allows you to use legacy database in your ORM application Low level control over the database Entity Data Model can be updated whenever database schema changes. Database-first approach supports stored procedure, view, etc. MODEL FIRST Creating a model using the Entity Framework designer tools Designer can generate DDL statements to create the database An easy-to-use UI allows quickly create new entities Separation of code and database in a declarative format Dropping and re-creating the database is not a choice This uses an .EDMX file to store model and mapping information. CODE FIRST The primary focus is getting the code and logic Define entity model with classes and mappings in code.. Entity Framework create (and recreate) the database for you. Does not use Entity Framework visual design tool, neither to design entities There is no XML file – no EDMX file – to represent model and storage schemas
  • 9. HOW TOs The steps involved in this example are as follows: Create the new SQL Server database Create the database objects Create a new C# Class Library Project in Visual Studio 2012 Solution Add a new ADO.NET Entity Data Model to project Create a new Database Connection Import the database objects into the EDM Modify the EDM to accommodate the scalar-valued functions
  • 15. HOW TOs The steps involved in this example are as follows: Creating the model Creating entities in the .edmx Editing entity properties Applying relationships to the entities  Name DatabaseSchema Generating the database from the model
  • 21. 16 17 18 19 20 21
  • 23. HOW TOs The steps involved in this example are as follows: Create a new Class Library Create POCO (Plain Old CLR Object) classes Add data annotations to the POCO classes. Create enum classes (if required) Add Entity Framework to the Solution Add a DbContext class Add ‘Code First Migrations’ Updates the database (if needed/made changes)
  • 26. 07
  • 27. FEATURES • Works with a variety of database servers (including Microsoft SQL server, oracle, and DB2) • Rich mapping engine handle real-world database and work with stored procedure • Generates strongly-typed entity objects that can be customized beyond 1-1 mapping • Generates mapping/plumbing code • Translates LINQ queries to database queries • Materializes objects from data store calls • Tracks changes, generating updates/inserts
  • 28. Advantages • Reduced development time • Developers can work more application-centric • Free from hard-coded dependencies on a particular data engine • Mappings can be change without changing the application code • L2Eprovides validation for writing queries against a conceptual model • Integrates with all the .NET application programming models • Worked well with ASP.NET, WPF, WCF, and WCF Data Services
  • 29. Question & Answer “A wise man can learn more from a foolish question than a fool can learn from a wise answer.” Bruce Lee