SlideShare a Scribd company logo
Entity Framework
Agenda
● ORM
● EF Modelling
● LINQ
● EF Inheritance
● EF Concurrency
Why Database Layer
Object Impedance Mismatch - RDBMS and OOP
Object Conversions - RDBMS to OOP and OOP to RDBMS
Needs Easy Conversion Process - Rise of ORM
ORM?
Many Frameworks - EF, NH, LINQ to SQL
RDBMS to NoSQL Support
Single RDBMS Support to Various RDBMS Support
DB Layer Uniformity Across the Organization
Entity Framework - Roadmap
EF - Key Terms
Entity
Context - Object Context, Db Context
Deferred Execution
POCO - Plain Old CLR Object
LINQ to Entities, Entity SQL
Mapping, Conceptual Model, Storage Model
Projections
EF - Resultant Objects
IEnumerable vs IQueryable
EF - Loading
Lazy, Eager Loading and Explicit Loading
Loading Navigation Properties
1. LazyLoadingEnabled = true
2. LazyLoadingEnabled = false & Include(“{Navigation Property}”)
3. LazyLoadingEnabled = false & {Navigation Property}.Load()
Modelling - .edmx
Modelling - .edmx - Types
Database First
Model First
Modelling - Database First
Reverse engineer model in EF Designer
Classes auto-generated from model
Preferred approach for existing database
Hands On
Database First - Tables, Stored Procedures, Views, Functions
Update Model
Modelling - Model First
Create model in EF Designer
Generate database from model
Classes auto-generated from model
Preferred approach for new database.
Hands On
Model First - Create Model, Generate Database
Update Model
Modelling - Code First
Define classes and mapping in code
Database created from code
Migrations apply model changes to database
Preferred approach for new database. Generally
preferred in Agile/Scrum
Modelling - Fluent Api, Configuration and Conventions
Fluent Api - Chaining Api
Configuration with Fluent Api
Conventions
Hands On
Code First - Create Classes with Conventions only
Database Generation
Database Migration
EF - CRUD
EF - Read Operation
EF - Create - Single Record
EF - Create - Multiple Records
EF - Update Record
EF - Delete Record
Homework
AddressBook - Design Db and Do CRUD operations on all entities
EF - LINQ
Filtering, Ordering
Joining
Grouping
EF - LINQ - Filtering, Ordering
EF - LINQ - Joining
EF - LINQ - Grouping
Homework
Full Outer Join Possible?
Use of “let” variable
EF - Code First
Conventions
Data Annotations
FluentApi
EF - Code First - Conventions
Convention: Table Name
Default: Entity + s (e.g Users)
Convention: Primary Key
Default: Id
Convention: Foreign Key Relation
Default: Entity + Id (e.g SubscriptionId)
EF - Code First - Data Annotations
Annotation: Table
=> Table(“{Name”})
Annotation: Key
=> Key
Annotation: ForeignKey
=> ForeignKey(“{Navigation Property”})
=> ForeignKey(“{Property”})
EF - Code First - Fluent Api
Homework
AddressBook - Design Db and Do CRUD operations on all entities
Executing Raw SQL - Plain, Stored Procedures
EF - Inheritance Strategy - TPH
EF - Inheritance Strategy - TPH
Needs a column, discriminator, that will used to identify exact type.
Retrieving Type in TPH
Code First Configuration
Gives better performance but there are many duplicate data and nullable columns.
EF - Inheritance Strategy - TPT
EF - Inheritance Strategy - TPT
Each entity maps to table. So CUD operations are faster
Code First Configuration
Retrieval is slower than TPH as it needs joins with base class/table.
EF - Inheritance Strategy - TPC
EF - Inheritance Strategy - TPC
Each concrete entity maps to table.
Code First Configuration
Properties of abstract entity are combined with concrete entity and many data/columns duplications.
EDMX designer does not support this mapping. Manual modification is required.
EF - Relationships
One to One
One to Many
Many to Many
EF - Relationships - One to One
EF - Relationships - One to Many
EF - Relationships - Many to Many
Hands On
One to One
One to Many
Many to Many
EF - Concurrency
Optimistic
Pessimistic
EF - Concurrency - Optimistic
None: Default and there is no concurrency
Fixed: Original value of concurrency column is included in where part while generating SQL
Rows are not locked. Read operation can be never locked
EF - Concurrency - Optimistic
Sample Code
EF - Concurrency - Pessimistic
Involves database locking operations. So it is slow
Use Transaction to achieve it
Read operation can be locked
Questions
Thank you
EF - Advance
Table Splitting
After little bit experience, it is worth
Bounded Contexts
After little bit experience, it is worth
EF - Unit Testing
After little bit experience, it is worth
EF - Patterns
After little bit experience, it is worth

More Related Content

What's hot (20)

PPTX
Entity framework code first
Confiz
 
PPTX
Entity Framework 4
Stefano Paluello
 
PPTX
Entity Framework - Object Services
Eyal Vardi
 
PPTX
Spring Data - Intro (Odessa Java TechTalks)
Igor Anishchenko
 
PPT
Object Relational model for SQLIite in android
yugandhar vadlamudi
 
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
PPT
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
PDF
NHibernate (The ORM For .NET Platform)
Samnang Chhun
 
PDF
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
 
PPT
Introduction to NHibernate
Dublin Alt,Net
 
PDF
.NET Core, ASP.NET Core Course, Session 15
Amin Mesbahi
 
PPTX
NHibernate for .NET
Guo Albert
 
KEY
Core Data
Robert Brown
 
PDF
Data Persistence in Android with Room Library
Reinvently
 
PPTX
AAC Room
선옥 장
 
ODP
Spring Data in 10 minutes
Corneil du Plessis
 
PDF
Advanced Core Data
Make School
 
PPTX
LINQ in C#
Basant Medhat
 
PPTX
Hibernate in Nutshell
Onkar Deshpande
 
KEY
Introducing LINQ
LearnNowOnline
 
Entity framework code first
Confiz
 
Entity Framework 4
Stefano Paluello
 
Entity Framework - Object Services
Eyal Vardi
 
Spring Data - Intro (Odessa Java TechTalks)
Igor Anishchenko
 
Object Relational model for SQLIite in android
yugandhar vadlamudi
 
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
NHibernate (The ORM For .NET Platform)
Samnang Chhun
 
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
 
Introduction to NHibernate
Dublin Alt,Net
 
.NET Core, ASP.NET Core Course, Session 15
Amin Mesbahi
 
NHibernate for .NET
Guo Albert
 
Core Data
Robert Brown
 
Data Persistence in Android with Room Library
Reinvently
 
AAC Room
선옥 장
 
Spring Data in 10 minutes
Corneil du Plessis
 
Advanced Core Data
Make School
 
LINQ in C#
Basant Medhat
 
Hibernate in Nutshell
Onkar Deshpande
 
Introducing LINQ
LearnNowOnline
 

Viewers also liked (12)

PPTX
Maven ii
Hasan Syed
 
PPTX
Simple web service vm
Hasan Syed
 
PPTX
Mi cerebro y yo – el dinero
emmanuelpocovi
 
PPTX
El marginalismo
emmanuelpocovi
 
PDF
SREEJITH_CV
sreejith soman nair
 
PPTX
Recursamiento diseña-y-administra-plataformas-e-learning
José Manuel Vázquez Aguila
 
PPTX
Jenkins3
Hasan Syed
 
PDF
Moss-Adams_2012-Corp-Social-Responsibility-Report
John Witt
 
DOCX
Trabajo de cultura ciudadana
Vidal Rivera Diaz
 
PPTX
John keynes
emmanuelpocovi
 
DOC
Shamal Solutions resume
Jeff Severson
 
PPTX
Caching and invalidating with managed store
Hasan Syed
 
Maven ii
Hasan Syed
 
Simple web service vm
Hasan Syed
 
Mi cerebro y yo – el dinero
emmanuelpocovi
 
El marginalismo
emmanuelpocovi
 
SREEJITH_CV
sreejith soman nair
 
Recursamiento diseña-y-administra-plataformas-e-learning
José Manuel Vázquez Aguila
 
Jenkins3
Hasan Syed
 
Moss-Adams_2012-Corp-Social-Responsibility-Report
John Witt
 
Trabajo de cultura ciudadana
Vidal Rivera Diaz
 
John keynes
emmanuelpocovi
 
Shamal Solutions resume
Jeff Severson
 
Caching and invalidating with managed store
Hasan Syed
 
Ad

Similar to Entity Framework (20)

PPTX
Using entity framework core in .net
Sophie Obomighie
 
PPTX
Applying EF Code First at Your Job
Enea Gabriel
 
PPTX
Ado.net entity framework_4.0
Rishu Mehra
 
PDF
Exceptions are the Norm: Dealing with Bad Actors in ETL
Databricks
 
PDF
.NET Core, ASP.NET Core Course, Session 16
Amin Mesbahi
 
PDF
Efficient processing of large and complex XML documents in Hadoop
DataWorks Summit
 
ODP
Cakefest higher education
therealphpdiddy
 
PDF
Using Apache Spark as ETL engine. Pros and Cons
Provectus
 
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
PPT
Entity framework 4.0
Abhishek Sur
 
PDF
PDI data vault framework #pcmams 2012
Jos van Dongen
 
PDF
Presentation pdi data_vault_framework_meetup2012
Pentaho Community
 
PPTX
PostgREST Design Philosophy
begriffs
 
PDF
Entity Framework Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
Tomáš Herceg "Entity Framework Core 2.1 – what’s new?"
Fwdays
 
PPT
Ling to SQL and Entity Framework performance analysis
Alexander Konduforov
 
PPTX
04 integrate entityframework
Erhwen Kuo
 
PPTX
Entity Core with Core Microservices.pptx
Knoldus Inc.
 
PPTX
EF6 or EF Core? How Do I Choose?
Julie Lerman
 
PDF
Application architecture
Iván Stepaniuk
 
Using entity framework core in .net
Sophie Obomighie
 
Applying EF Code First at Your Job
Enea Gabriel
 
Ado.net entity framework_4.0
Rishu Mehra
 
Exceptions are the Norm: Dealing with Bad Actors in ETL
Databricks
 
.NET Core, ASP.NET Core Course, Session 16
Amin Mesbahi
 
Efficient processing of large and complex XML documents in Hadoop
DataWorks Summit
 
Cakefest higher education
therealphpdiddy
 
Using Apache Spark as ETL engine. Pros and Cons
Provectus
 
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Entity framework 4.0
Abhishek Sur
 
PDI data vault framework #pcmams 2012
Jos van Dongen
 
Presentation pdi data_vault_framework_meetup2012
Pentaho Community
 
PostgREST Design Philosophy
begriffs
 
Entity Framework Interview Questions PDF By ScholarHat
Scholarhat
 
Tomáš Herceg "Entity Framework Core 2.1 – what’s new?"
Fwdays
 
Ling to SQL and Entity Framework performance analysis
Alexander Konduforov
 
04 integrate entityframework
Erhwen Kuo
 
Entity Core with Core Microservices.pptx
Knoldus Inc.
 
EF6 or EF Core? How Do I Choose?
Julie Lerman
 
Application architecture
Iván Stepaniuk
 
Ad

Recently uploaded (20)

PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
What companies do with Pharo (ESUG 2025)
ESUG
 
PDF
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
What companies do with Pharo (ESUG 2025)
ESUG
 
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 

Entity Framework

Editor's Notes

  • #50: http://www.codeproject.com/Articles/114262/ways-of-doing-locking-in-NET-Pessimistic-and-opt