SlideShare uma empresa Scribd logo
1 de 20
Microsoft
Entity Framework
Microsoft Entity Framework
•

Microsoft Entity framework is one of the best object relational mapping frameworks.

•

Facilitates accessing databases and other relational data sources rather than the other frameworks.

•

The current version is EF 6.0 (see http://msdn.microsoft.com/en-us/data/jj574253.aspx)
Object Relational Mapping (ORM)
It is a tool for storing data from domain objects to relational database like MS SQL Server in an automated way without much
programming. O/RM includes three main parts: Domain class objects, Relational database objects and Mapping information on
how domain objects maps to relational database objects (tables, views & stored procedures). ORM helps us to keep our
database design separate from our domain class design. This makes application maintainable and extendable. It also automates
standard CRUD operation (Create, Read, Update & Delete) so developer doesn’t need to write it manually
ORM tools


ADO.NET Entity Framework, Microsoft’s ORM (released with .NET 3.5 SP1)



Base One Foundation Component Library, free or commercial



BCSEi ORM Code Generator, free or commercial



Business Logic Toolkit for .NET, open source



Castle ActiveRecord, ActiveRecord for .NET, open source



DataObjects.Net v4.0, open source, commercial



DevForce, commercial, N-Tier



Developer Express, eXpress Persistent Objects (XPO)



EntitySpaces, commercial
ORM Tools (Cont.)
























Euss, open source
Habanero, Free open source
BATIS, Free open source
Invist,free ORM and code generation tool
LLBLGen, open source drivers, commercial
LightSpeed, free or commercial
Neo, open source
NConstruct, commercial
NHibernate, open source
Opf3, free and commercial
ObjectMapper .NET, GPL and commercial license
OpenAccess, free or commercial
TierDeveloper, free ORM and code generation tool
Persistor.NET, free or commercial
Quick Objects, free or commercial
Sooda, open source; BSD license
Subsonic, open source
Orasis, free trial or buy.
Telerik, express or buy.
CSLA.NET, free.
ECO, free or commercial
nhydrate, open source
.netTiers, open source
Why Entity Framework
 Domain model pattern, using this pattern means that you model your entities based on your business concepts

rather than the database layer. Provides mapping from logical layer to the physical layer.
 Huge code reduction, allows developers to focus on the business logic and providing automated code for storing
and accessing the database
 There is no SQL update, insert, delete statements written in different layers of the application.
 Rich query capability, by providing rich object oriented query language.
 Navigation. You can navigate object relationships transparently.

 Concurrency, allowing multiple users updating the same data simultaneously.
Entity Framework vs. Linq To SQL
Entity Framework

LinQ to SQL (L2S)

Full provider model, supports DB2, Oracle, MySQL,
SQL

Limited provider model

Model entities can map to one or more tables using
table per type or table per inheritance

One entity only maps to a single table

Continuous support

Microsoft is no longer supports it

Multiple modeling techniques

Only single model technique
Entity Framework Architecture
1.
2.
3.
4.
5.

Entity Data Model
Linq to Entities
Entity SQL
Object Service “The entry point for accessing database and returning data to it”
Entity Client data provider “Responsible for converting L2E and Entity SQL queries to database
queries”
6. ADO.NET data provider “this layer communicates
directly with the database using standard ADO.NET”
EF Code First
There are two new types introduced for Code First approach, DbContext and DbSet. DbContext is a simplified alternative
to ObjectContext and is the primary object for interacting with a database using a specific model. DbSet(Of TEntity) is a
simplified alternative to ObjectSet(Of TEntity) and is used to perform CRUD operations against a specific type from the
model in Code First approach.

•

To include the entity framework in your project using nugget

Type get-package -remote -filter entityframework then type install-package -id EntityFramework
•

use data annotations to specify properties at the target database.

mahmoodfcis@gmail.com
Code first to an existing database
Install entity framework power tools from visual studio gallery
http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
Just right click the project and select reverse engineer Code First

mahmoodfcis@gmail.com
Performing CRUD operations

mahmoodfcis@gmail.com
Query
1. Linq To Entities
2.

Entity SQL

mahmoodfcis@gmail.com
Query
3. Native SQL

//Querying with native sql using (SchoolDBEntities ctx = new SchoolDBEntities()) { //Inserting Student using
ExecuteStoreCommand
int InsertedRows = ctx.ExecuteStoreCommand("Insert into Student(StudentName,StandardId)
values('StudentName1',1)");
//Fetching student using ExecuteStoreQuery
var student = ctx.ExecuteStoreQuery<Student>("Select * from Student where StudentName = 'StudentName1'",
null).ToList(); }

mahmoodfcis@gmail.com
Update entities

mahmoodfcis@gmail.com
Self Tracking Entities
There is common problem when using entity framework with multitier application, entities lose states
outside the scope of an object context,

Solution: Self tracking entities

mahmoodfcis@gmail.com
Add new entities

mahmoodfcis@gmail.com
Delete Entities

mahmoodfcis@gmail.com
Concurrency
A concurrency conflict occurs when one user displays an entity's data in order to edit it, and then another user updates
the same entity's data before the first user's change is written to the database. If you don't enable the detection of such
conflicts, whoever updates the database last overwrites the other user's changes.

There are two types of concurrency
1. Pessimistic Concurrency (Locking)
2. Optimistic Concurrency

mahmoodfcis@gmail.com
Transactions
We use transactions when multiple calls of SaveChanges are called or when multiple operations are performed on a
single entity object.

There are two approaches for performing Transactions
1. DbTransaction
2. TransactionScope

mahmoodfcis@gmail.com
EF performance Tuning
1. Efficiently load related data
2. Use NoTracking merge option
3. Pre-Compile linQ queries
private static readonly Func<SchoolEntities, IQueryable<InstructorName>>
compiledInstructorNamesQuery = CompiledQuery.Compile((SchoolEntities context) => from i in
context.InstructorNames orderby i.FullName select i);

1. Examine query commands sent to the database.

mahmoodfcis@gmail.com

Mais conteúdo relacionado

Mais procurados

Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)Eyal Vardi
 
Entity framework and how to use it
Entity framework and how to use itEntity framework and how to use it
Entity framework and how to use itnspyre_net
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overviewukdpe
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework OverviewEric Nelson
 
Building nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesBuilding nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesDavid McCarter
 
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows AzureCloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows AzureDavid Chou
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsRichie Rump
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity FrameworkLearnNowOnline
 
Entity Framework - Queries
Entity Framework -  QueriesEntity Framework -  Queries
Entity Framework - QueriesEyal Vardi
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity FrameworkDoncho Minkov
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggetsVirtual Nuggets
 
IRJET- Review on Java Database Connectivity
IRJET- Review on Java Database ConnectivityIRJET- Review on Java Database Connectivity
IRJET- Review on Java Database ConnectivityIRJET Journal
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
 

Mais procurados (20)

Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)
 
Entity framework and how to use it
Entity framework and how to use itEntity framework and how to use it
Entity framework and how to use it
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
Building nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesBuilding nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework Services
 
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows AzureCloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
Day2
Day2Day2
Day2
 
Day7
Day7Day7
Day7
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity Framework
 
Entity Framework - Queries
Entity Framework -  QueriesEntity Framework -  Queries
Entity Framework - Queries
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
 
Ado .net
Ado .netAdo .net
Ado .net
 
IRJET- Review on Java Database Connectivity
IRJET- Review on Java Database ConnectivityIRJET- Review on Java Database Connectivity
IRJET- Review on Java Database Connectivity
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
 

Destaque

Universities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsenseUniversities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsensediharrison
 
The role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paperThe role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paperdiharrison
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication FoundationMahmoud Tolba
 
Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...diharrison
 
So that's it for it services, or is it?
So that's it for it services, or is it?So that's it for it services, or is it?
So that's it for it services, or is it?diharrison
 

Destaque (6)

Universities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsenseUniversities And Social Networking: making sense out of nonsense
Universities And Social Networking: making sense out of nonsense
 
The role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paperThe role of the central IT Services organisation in a Web 2.0 world - paper
The role of the central IT Services organisation in a Web 2.0 world - paper
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...Disruptive technologies and the implications for University Information Servi...
Disruptive technologies and the implications for University Information Servi...
 
So that's it for it services, or is it?
So that's it for it services, or is it?So that's it for it services, or is it?
So that's it for it services, or is it?
 

Semelhante a Microsoft Entity Framework

Entity Framework Core 1.0
Entity Framework Core 1.0Entity Framework Core 1.0
Entity Framework Core 1.0Senthil Kumar
 
Data modeling star schema
Data modeling star schemaData modeling star schema
Data modeling star schemaSayed Ahmed
 
Be a database professional
Be a database professionalBe a database professional
Be a database professionalSayed Ahmed
 
Be a database professional
Be a database professionalBe a database professional
Be a database professionalSayed Ahmed
 
Asp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkAsp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkShravan A
 
Entity framework introduction sesion-1
Entity framework introduction   sesion-1Entity framework introduction   sesion-1
Entity framework introduction sesion-1Usama Nada
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstEnea Gabriel
 
Entity Framework V1 and V2
Entity Framework V1 and V2Entity Framework V1 and V2
Entity Framework V1 and V2ukdpe
 
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource GroupLINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource GroupShahzad
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?ukdpe
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh Kumar
 
Entity Framework v1 and v2
Entity Framework v1 and v2Entity Framework v1 and v2
Entity Framework v1 and v2Eric Nelson
 
Martin Koons Resume 2015
Martin Koons Resume 2015Martin Koons Resume 2015
Martin Koons Resume 2015Marty Koons
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010Ethos Technologies
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010David McCarter
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
 

Semelhante a Microsoft Entity Framework (20)

70487.pdf
70487.pdf70487.pdf
70487.pdf
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
 
Entity Framework Core 1.0
Entity Framework Core 1.0Entity Framework Core 1.0
Entity Framework Core 1.0
 
Data modeling star schema
Data modeling star schemaData modeling star schema
Data modeling star schema
 
Be a database professional
Be a database professionalBe a database professional
Be a database professional
 
Be a database professional
Be a database professionalBe a database professional
Be a database professional
 
Asp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkAsp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity Framework
 
Entity framework introduction sesion-1
Entity framework introduction   sesion-1Entity framework introduction   sesion-1
Entity framework introduction sesion-1
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Entity Framework V1 and V2
Entity Framework V1 and V2Entity Framework V1 and V2
Entity Framework V1 and V2
 
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource GroupLINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Entity Framework v1 and v2
Entity Framework v1 and v2Entity Framework v1 and v2
Entity Framework v1 and v2
 
Martin Koons Resume 2015
Martin Koons Resume 2015Martin Koons Resume 2015
Martin Koons Resume 2015
 
CG_CS25010_Lecture
CG_CS25010_LectureCG_CS25010_Lecture
CG_CS25010_Lecture
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 
Ef overview
Ef overviewEf overview
Ef overview
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 

Mais de Mahmoud Tolba

The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmerMahmoud Tolba
 
Introduction to SAP, Systems, Applications
Introduction to SAP, Systems, ApplicationsIntroduction to SAP, Systems, Applications
Introduction to SAP, Systems, ApplicationsMahmoud Tolba
 
Developing cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache CordovaDeveloping cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache CordovaMahmoud Tolba
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllersMahmoud Tolba
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 OverviewMahmoud Tolba
 
Top emerging technologies
Top emerging technologiesTop emerging technologies
Top emerging technologiesMahmoud Tolba
 

Mais de Mahmoud Tolba (8)

The passionate programmer
The passionate programmerThe passionate programmer
The passionate programmer
 
Introduction to SAP, Systems, Applications
Introduction to SAP, Systems, ApplicationsIntroduction to SAP, Systems, Applications
Introduction to SAP, Systems, Applications
 
AngularJS
AngularJSAngularJS
AngularJS
 
Developing cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache CordovaDeveloping cross platforms mobile applications using the Apache Cordova
Developing cross platforms mobile applications using the Apache Cordova
 
JQuery Overview
JQuery OverviewJQuery Overview
JQuery Overview
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllers
 
ASP.NET MVC4 Overview
ASP.NET MVC4 OverviewASP.NET MVC4 Overview
ASP.NET MVC4 Overview
 
Top emerging technologies
Top emerging technologiesTop emerging technologies
Top emerging technologies
 

Último

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 

Último (20)

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

Microsoft Entity Framework

  • 2. Microsoft Entity Framework • Microsoft Entity framework is one of the best object relational mapping frameworks. • Facilitates accessing databases and other relational data sources rather than the other frameworks. • The current version is EF 6.0 (see http://msdn.microsoft.com/en-us/data/jj574253.aspx)
  • 3. Object Relational Mapping (ORM) It is a tool for storing data from domain objects to relational database like MS SQL Server in an automated way without much programming. O/RM includes three main parts: Domain class objects, Relational database objects and Mapping information on how domain objects maps to relational database objects (tables, views & stored procedures). ORM helps us to keep our database design separate from our domain class design. This makes application maintainable and extendable. It also automates standard CRUD operation (Create, Read, Update & Delete) so developer doesn’t need to write it manually
  • 4. ORM tools  ADO.NET Entity Framework, Microsoft’s ORM (released with .NET 3.5 SP1)  Base One Foundation Component Library, free or commercial  BCSEi ORM Code Generator, free or commercial  Business Logic Toolkit for .NET, open source  Castle ActiveRecord, ActiveRecord for .NET, open source  DataObjects.Net v4.0, open source, commercial  DevForce, commercial, N-Tier  Developer Express, eXpress Persistent Objects (XPO)  EntitySpaces, commercial
  • 5. ORM Tools (Cont.)                        Euss, open source Habanero, Free open source BATIS, Free open source Invist,free ORM and code generation tool LLBLGen, open source drivers, commercial LightSpeed, free or commercial Neo, open source NConstruct, commercial NHibernate, open source Opf3, free and commercial ObjectMapper .NET, GPL and commercial license OpenAccess, free or commercial TierDeveloper, free ORM and code generation tool Persistor.NET, free or commercial Quick Objects, free or commercial Sooda, open source; BSD license Subsonic, open source Orasis, free trial or buy. Telerik, express or buy. CSLA.NET, free. ECO, free or commercial nhydrate, open source .netTiers, open source
  • 6. Why Entity Framework  Domain model pattern, using this pattern means that you model your entities based on your business concepts rather than the database layer. Provides mapping from logical layer to the physical layer.  Huge code reduction, allows developers to focus on the business logic and providing automated code for storing and accessing the database  There is no SQL update, insert, delete statements written in different layers of the application.  Rich query capability, by providing rich object oriented query language.  Navigation. You can navigate object relationships transparently.  Concurrency, allowing multiple users updating the same data simultaneously.
  • 7. Entity Framework vs. Linq To SQL Entity Framework LinQ to SQL (L2S) Full provider model, supports DB2, Oracle, MySQL, SQL Limited provider model Model entities can map to one or more tables using table per type or table per inheritance One entity only maps to a single table Continuous support Microsoft is no longer supports it Multiple modeling techniques Only single model technique
  • 8. Entity Framework Architecture 1. 2. 3. 4. 5. Entity Data Model Linq to Entities Entity SQL Object Service “The entry point for accessing database and returning data to it” Entity Client data provider “Responsible for converting L2E and Entity SQL queries to database queries” 6. ADO.NET data provider “this layer communicates directly with the database using standard ADO.NET”
  • 9. EF Code First There are two new types introduced for Code First approach, DbContext and DbSet. DbContext is a simplified alternative to ObjectContext and is the primary object for interacting with a database using a specific model. DbSet(Of TEntity) is a simplified alternative to ObjectSet(Of TEntity) and is used to perform CRUD operations against a specific type from the model in Code First approach. • To include the entity framework in your project using nugget Type get-package -remote -filter entityframework then type install-package -id EntityFramework • use data annotations to specify properties at the target database. mahmoodfcis@gmail.com
  • 10. Code first to an existing database Install entity framework power tools from visual studio gallery http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d Just right click the project and select reverse engineer Code First mahmoodfcis@gmail.com
  • 12. Query 1. Linq To Entities 2. Entity SQL mahmoodfcis@gmail.com
  • 13. Query 3. Native SQL //Querying with native sql using (SchoolDBEntities ctx = new SchoolDBEntities()) { //Inserting Student using ExecuteStoreCommand int InsertedRows = ctx.ExecuteStoreCommand("Insert into Student(StudentName,StandardId) values('StudentName1',1)"); //Fetching student using ExecuteStoreQuery var student = ctx.ExecuteStoreQuery<Student>("Select * from Student where StudentName = 'StudentName1'", null).ToList(); } mahmoodfcis@gmail.com
  • 15. Self Tracking Entities There is common problem when using entity framework with multitier application, entities lose states outside the scope of an object context, Solution: Self tracking entities mahmoodfcis@gmail.com
  • 18. Concurrency A concurrency conflict occurs when one user displays an entity's data in order to edit it, and then another user updates the same entity's data before the first user's change is written to the database. If you don't enable the detection of such conflicts, whoever updates the database last overwrites the other user's changes. There are two types of concurrency 1. Pessimistic Concurrency (Locking) 2. Optimistic Concurrency mahmoodfcis@gmail.com
  • 19. Transactions We use transactions when multiple calls of SaveChanges are called or when multiple operations are performed on a single entity object. There are two approaches for performing Transactions 1. DbTransaction 2. TransactionScope mahmoodfcis@gmail.com
  • 20. EF performance Tuning 1. Efficiently load related data 2. Use NoTracking merge option 3. Pre-Compile linQ queries private static readonly Func<SchoolEntities, IQueryable<InstructorName>> compiledInstructorNamesQuery = CompiledQuery.Compile((SchoolEntities context) => from i in context.InstructorNames orderby i.FullName select i); 1. Examine query commands sent to the database. mahmoodfcis@gmail.com

Notas do Editor

  1. In Slide Show mode, click the arrow to enter the PowerPoint Getting Started Center.