SlideShare une entreprise Scribd logo
1  sur  17
Lushanthan S.



getting started with Microsoft

Entity Framework
Today’s Agenda
 Introduction

 The Architecture

 Entity Data Model

 The Conceptual Model – .edmx file, exploring the classes

 Demo
    LINQ to Entities
    Lazy Loading
    CRUD
    Stored Procedures

 Shipped Products
Our life so far…
               All of us have worked on Data access!
               Objects != Relational Data – “Impedance mismatch”
Introduction




               Languages     C#                        SQL

               Tools         Visual Studio             SQL Server

               Paradigms     Object                    Procedural

               Common API     ADO.NET


               Powerful, but fragile and time consuming!
Legacy ADO.NET
               Sample Code:
                    using (SqlConnection conn = new SqlConnection("<conn string>"))
                               {
                                   conn.Open();
                                   SqlCommand cmd = conn.CreateCommand();
                                   cmd.CommandText = "sp_StoredProc";
                                   cmd.parameters.AddWithValue("@City", "Colombo");

                                   using (SqlDataReader rdr = cmd.ExecuteReader())
                                   {
                                       while (rdr.read())
                                       {
Introduction




                                           string name = rdr.GetString(0);
                                           string city = rdr.GetString(1);
                                       }
                                   }
                              }




               Loosely typed!
microsoft giving this to us as a
What about

Product?
                 Yes, there comes Microsoft Entity Framework
History of Data Access in .Net

               ADO.Net Inline SQL
               Data Sets
               Stored Procedures
               ORM - Typed Data Sets, LINQ to SQL, EF1, EF4
Introduction




               Bridging the gap between objects and relational data!
What is Entity Framework?
               Released in July 2008, EF is a data access framework from
               Microsoft that helps to bridge the gap between data structures
               and objects in your applications.

               What does it really do?
               It automatically,
Introduction




                    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
The Architecture   Under the hood
Bird’s Eye View

                         Entity Framework

                         LINQ to Entities, Entity SQL, Query
                         builder methods
                                                                   Programming
                         ADO.NET Entity Provider (entity client)   Model
The Architecture




                         Conceptual Data Model




                          Legacy ADO.NET does not go away!

                     ADO.NET Data Provider
                     (SqlClient, OracleClient)

                          Reader                 Connection
                                                                                 Store
                          Adapter                Command
Entity Data Model
                     Set of objects that describe structure of your business
                     data and map to your underlying data store.

                       Contained in Three XML sections stored in *.edmx file:
Entity Data Model




                        Database                                         Entity
                        Schema                                           Objects

                         Storage Model             Mapping               Conceptual Model


                    Database                                        UI          OO     Services
The Conceptual Model   The Conceptual Model
 Exploring the conceptual
                                       model

                                      Database First

                                      Model First

                                      LINQ to Entities

                                      CRUD

                                      Lazy Loading
Demo                                  Include()

Following sections will be covered    Stored Procedures
                                     .

.
Shipped Products
                    Entity Framework 1.0 (.NET 3.5 SP1/ VS 2008 SP1 )

                    Entity Framework 4.0 (.NET 4/ VS 2010 )
                      • Model-First support
                      • Foreign Keys in the conceptual Model
Shipped Products




                      • Lazy loading
                      • Persistence-Ignorant Objects (POCO) support
                      • Self-Tracking Entities

                    Entity Framework 4.1, 4.2, 4.3 (.NET 4/ VS 2010 )
                      • Code-first Migration

                    Entity Framework 5.0 beta1, 2 (.NET 4.5 Beta/ VS 2011 Beta )
                      • Enum support
                      • Tabled valued functions support
Linq to SQL Vs Entity Framework

L2S
      Strongly typed LINQ access for RAD against SQL Server only
      Support s only direct Table-Per-Type (1-to-1) mapping
      Limited out-of-the box support for complex scenarios
EF
      Designed for larger enterprise applications
      Enables complex mapping complex scenarios
      Tools and designer more robust
      Supports inheritance and many-to-many relationships
      Supports provider independence


                                14
?
    But wait…
    There’s More!
Areas not covered

 POCO Entities

 Entity SQL

 T4 Templates

 Code first Approach




                        16
The End

Microsoft

Entity Framework
Q & A Session

Contenu connexe

Tendances

Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Khaled Musaied
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
guest11106b
 

Tendances (20)

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Web api
Web apiWeb api
Web api
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Collections and its types in C# (with examples)
Collections and its types in C# (with examples)
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 

En vedette

05 entity framework
05 entity framework05 entity framework
05 entity framework
glubox
 

En vedette (20)

Introducing Entity Framework 4.0
Introducing Entity Framework 4.0Introducing Entity Framework 4.0
Introducing Entity Framework 4.0
 
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
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 
Lerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In AspnetLerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In Aspnet
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
Using sql server in c sharp
Using sql server in c sharpUsing sql server in c sharp
Using sql server in c sharp
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Getting started with entity framework 6 code first using mvc 5
Getting started with entity framework 6 code first using mvc 5Getting started with entity framework 6 code first using mvc 5
Getting started with entity framework 6 code first using mvc 5
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
 
Ado .net
Ado .netAdo .net
Ado .net
 
Dotnet differences compiled -1
Dotnet differences compiled -1Dotnet differences compiled -1
Dotnet differences compiled -1
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
 
Entity Framework and Domain Driven Design
Entity Framework and Domain Driven DesignEntity Framework and Domain Driven Design
Entity Framework and Domain Driven Design
 
Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
Case Study # Odoo Implementation @ Samuda Chemical Complex Ltd
Case Study # Odoo Implementation @ Samuda Chemical Complex LtdCase Study # Odoo Implementation @ Samuda Chemical Complex Ltd
Case Study # Odoo Implementation @ Samuda Chemical Complex Ltd
 

Similaire à Getting started with entity framework

Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09
manisoft84
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
ukdpe
 

Similaire à Getting started with entity framework (20)

Entity Framework v1 and v2
Entity Framework v1 and v2Entity Framework v1 and v2
Entity Framework v1 and v2
 
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
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
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)
 
5c8605.ado.net
5c8605.ado.net5c8605.ado.net
5c8605.ado.net
 
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 Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
 
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
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
Microsoft Data Access Technologies
Microsoft Data Access TechnologiesMicrosoft Data Access Technologies
Microsoft Data Access Technologies
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Entity Framework Today (May 2012)
Entity Framework Today (May 2012)
 
Entity framework 4.0
Entity framework 4.0Entity framework 4.0
Entity framework 4.0
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
 
ADO.NET Entity Framework DevDays
ADO.NET Entity Framework DevDaysADO.NET Entity Framework DevDays
ADO.NET Entity Framework DevDays
 
Entity framework introduction sesion-1
Entity framework introduction   sesion-1Entity framework introduction   sesion-1
Entity framework introduction sesion-1
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Getting started with entity framework

  • 1. Lushanthan S. getting started with Microsoft Entity Framework
  • 2. Today’s Agenda  Introduction  The Architecture  Entity Data Model  The Conceptual Model – .edmx file, exploring the classes  Demo  LINQ to Entities  Lazy Loading  CRUD  Stored Procedures  Shipped Products
  • 3. Our life so far… All of us have worked on Data access! Objects != Relational Data – “Impedance mismatch” Introduction Languages C# SQL Tools Visual Studio SQL Server Paradigms Object Procedural Common API ADO.NET Powerful, but fragile and time consuming!
  • 4. Legacy ADO.NET Sample Code: using (SqlConnection conn = new SqlConnection("<conn string>")) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "sp_StoredProc"; cmd.parameters.AddWithValue("@City", "Colombo"); using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.read()) { Introduction string name = rdr.GetString(0); string city = rdr.GetString(1); } } } Loosely typed!
  • 5. microsoft giving this to us as a What about Product? Yes, there comes Microsoft Entity Framework
  • 6. History of Data Access in .Net ADO.Net Inline SQL Data Sets Stored Procedures ORM - Typed Data Sets, LINQ to SQL, EF1, EF4 Introduction Bridging the gap between objects and relational data!
  • 7. What is Entity Framework? Released in July 2008, EF is a data access framework from Microsoft that helps to bridge the gap between data structures and objects in your applications. What does it really do? It automatically, Introduction  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
  • 8. The Architecture Under the hood
  • 9. Bird’s Eye View Entity Framework LINQ to Entities, Entity SQL, Query builder methods Programming ADO.NET Entity Provider (entity client) Model The Architecture Conceptual Data Model Legacy ADO.NET does not go away! ADO.NET Data Provider (SqlClient, OracleClient) Reader Connection Store Adapter Command
  • 10. Entity Data Model Set of objects that describe structure of your business data and map to your underlying data store. Contained in Three XML sections stored in *.edmx file: Entity Data Model Database Entity Schema Objects Storage Model Mapping Conceptual Model Database UI OO Services
  • 11. The Conceptual Model The Conceptual Model
  • 12.  Exploring the conceptual model  Database First  Model First  LINQ to Entities  CRUD  Lazy Loading Demo  Include() Following sections will be covered  Stored Procedures . .
  • 13. Shipped Products  Entity Framework 1.0 (.NET 3.5 SP1/ VS 2008 SP1 )  Entity Framework 4.0 (.NET 4/ VS 2010 ) • Model-First support • Foreign Keys in the conceptual Model Shipped Products • Lazy loading • Persistence-Ignorant Objects (POCO) support • Self-Tracking Entities  Entity Framework 4.1, 4.2, 4.3 (.NET 4/ VS 2010 ) • Code-first Migration  Entity Framework 5.0 beta1, 2 (.NET 4.5 Beta/ VS 2011 Beta ) • Enum support • Tabled valued functions support
  • 14. Linq to SQL Vs Entity Framework L2S Strongly typed LINQ access for RAD against SQL Server only Support s only direct Table-Per-Type (1-to-1) mapping Limited out-of-the box support for complex scenarios EF Designed for larger enterprise applications Enables complex mapping complex scenarios Tools and designer more robust Supports inheritance and many-to-many relationships Supports provider independence 14
  • 15. ? But wait… There’s More!
  • 16. Areas not covered  POCO Entities  Entity SQL  T4 Templates  Code first Approach 16

Notes de l'éditeur

  1. The Entity Framework includes the EntityClient data provider. This provider manages connections, translates entity queries into data source-specific queries, and returns a data reader that the Entity Framework uses to materialize entity data into objects.
  2. 5.0 beta http://msdn.microsoft.com/en-us/library/hh551137%28VS.103%29.aspx
  3. http://daveswersky.com/2010/05/26/entity-framework-4-then-and-now/