SlideShare a Scribd company logo
The Entity Data Model




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Objectives




         Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Objectives
• Learn how to create and use an Entity Data
  Model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Objectives
• Learn how to create and use an Entity Data
  Model
• Explore the raw XML behind the model as a way
  to understand how Entity Framework works




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Objectives
• Learn how to create and use an Entity Data
  Model
• Explore the raw XML behind the model as a way
  to understand how Entity Framework works
• See how to use stored procedures within an
  Entity Framework model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model
• Entity Data Model in the Raw




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda
•   Introduction
•   Creating and Using an Entity Data Model
•   Entity Data Model in the Raw
•   Using Stored Procedures in the Model




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Introduction




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model
   Storage model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model
   Storage model
   Mapping model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model
   Storage model
   Mapping model
• Application design is often at odds with database
  design




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model
   Storage model
   Mapping model
• Application design is often at odds with database
  design
• Can work with model in designer




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model
   Storage model
   Mapping model
• Application design is often at odds with database
  design
• Can work with model in designer
   Or get messy with the XML



              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
    Conceptual model
    Storage model
    Mapping model
• Application design is often at odds with database
  design
• Can work with model in designer
    Or get messy with the XML
• At build, split into three XML files

               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Introduction
• Key link between entity objects and data
   Conceptual model
   Storage model
   Mapping model
• Application design is often at odds with database
  design
• Can work with model in designer
   Or get messy with the XML
• At build, split into three XML files
• Developers don’t have to know the database
              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model
   Represents the database schemas




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model
   Represents the database schemas
   Can be similar to conceptual model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model
   Represents the database schemas
   Can be similar to conceptual model
   Decupling of conceptual design from the database




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model
   Represents the database schemas
   Can be similar to conceptual model
   Decupling of conceptual design from the database
• Mapping Model


              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model
   Represents the database schemas
   Can be similar to conceptual model
   Decupling of conceptual design from the database
• Mapping Model
   Bridge between conceptual and storage models

              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
The Models within the Model
• Conceptual Model
   The actual Entity Data Model
   Provides what is needed to create data objects
• Storage Model
   Represents the database schemas
   Can be similar to conceptual model
   Decupling of conceptual design from the database
• Mapping Model
   Bridge between conceptual and storage models
   Map object properties to database fields
              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Agenda




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction




             Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model
• Entity Data Model in the Raw




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
•   Introduction
•   Creating and Using an Entity Data Model
•   Entity Data Model in the Raw
•   Using Stored Procedures in the Model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model
• Can create from scratch using XML




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model
• Can create from scratch using XML
   More productive using the designer




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model
• Can create from scratch using XML
   More productive using the designer
• Three approaches




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model
• Can create from scratch using XML
   More productive using the designer
• Three approaches
   Database-first




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model
• Can create from scratch using XML
   More productive using the designer
• Three approaches
   Database-first
   Model-first




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Creating and Using an Entity Data
Model
• Can create from scratch using XML
   More productive using the designer
• Three approaches
   Database-first
   Model-first
   Code-first




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Creating a Model Using Database-
First Design




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating a Model Using Database-
First Design
• Directly supported by the Entity Framework
  template




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Creating a Model Using Database-
First Design
• Directly supported by the Entity Framework
  template
• Wizard lets you




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Creating a Model Using Database-
First Design
• Directly supported by the Entity Framework
  template
• Wizard lets you
   Reverse-engineer the database schma




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Creating a Model Using Database-
First Design
• Directly supported by the Entity Framework
  template
• Wizard lets you
   Reverse-engineer the database schma
   Select tables, views, and stored procedures to include




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Creating a Model Using Database-
First Design
• Directly supported by the Entity Framework
  template
• Wizard lets you
   Reverse-engineer the database schma
   Select tables, views, and stored procedures to include
   Build the model from selected objects




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Multiplicity




           Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Multiplicity
• Used with associations




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality




                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options




                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1




                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1
    Zero or one: 0..1




                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1
    Zero or one: 0..1
    Many: *




                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1
    Zero or one: 0..1
    Many: *
• Can combine in various ways, such as



                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1
    Zero or one: 0..1
    Many: *
• Can combine in various ways, such as
    1:*



                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1
    Zero or one: 0..1
    Many: *
• Can combine in various ways, such as
    1:*
    0..1:*

                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Multiplicity
• Used with associations
• Number of entities that can be on each end of an
  association
    Sometimes referred to as cardinality
• Three options
    One: 1
    Zero or one: 0..1
    Many: *
• Can combine in various ways, such as
    1:*
    0..1:*
    *:*
                  Learn More @ http://www.learnnowonline.com
                     Copyright © by Application Developers Training Company
Entity Data Model Object Properties




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Entity Data Model Object Properties
• Typical for Visual Studio




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Entity Data Model Object Properties
• Typical for Visual Studio
• Use Properties windows to set values of
  properties for various objects




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Entity Data Model Object Properties
• Typical for Visual Studio
• Use Properties windows to set values of
  properties for various objects
• Model stores some in model’s XML to define a
  model, others guide object creation




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common
• Sometimes creating a new database with the
  application




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common
• Sometimes creating a new database with the
  application
   Could create the database first




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common
• Sometimes creating a new database with the
  application
   Could create the database first
   But model-first is another option




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common
• Sometimes creating a new database with the
  application
   Could create the database first
   But model-first is another option
   Strictly speaking, Entity Framework has always had
    this option




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common
• Sometimes creating a new database with the
  application
   Could create the database first
   But model-first is another option
   Strictly speaking, Entity Framework has always had
    this option
• Generate Database from Model option


              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Creating a Model Using
Model-First Design
• Database-first design is common
• Sometimes creating a new database with the
  application
   Could create the database first
   But model-first is another option
   Strictly speaking, Entity Framework has always had
    this option
• Generate Database from Model option
• Entity Designer Database Generation Power Pack

              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Sled Dog Event Registration




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Sled Dog Event Registration
                                                                       Team
   Event
                              Race                                     FirstName
   Name        1         *                         1             *
                              Distance                                 LastName
   EventDate
                              DogCount                                 City
   Sponsor
                              Trail                                    Country
   Location
                                                                       DogCount



                                             Mushing                   Skijoring
                                             Leader1                   Dog1
                                             Leader2                   Dog2
                                                                       Dog3
                                                                       NumberOfLeaders



               Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Explore the Model with the
Model Browser




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Explore the Model with the
Model Browser
• Working with large models can be hard in the
  designer




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Explore the Model with the
Model Browser
• Working with large models can be hard in the
  designer
   Can be hard to understand the structure of the model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Explore the Model with the
Model Browser
• Working with large models can be hard in the
  designer
   Can be hard to understand the structure of the model
   Mapping Details windows doesn’t have details of
    storage model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Explore the Model with the
Model Browser
• Working with large models can be hard in the
  designer
   Can be hard to understand the structure of the model
   Mapping Details windows doesn’t have details of
    storage model
• Overcome these limitations with the Model
  Browser




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Agenda




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction




             Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model
• Entity Data Model in the Raw




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda
•   Introduction
•   Creating and Using an Entity Data Model
•   Entity Data Model in the Raw
•   Using Stored Procedures in the Model




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Entity Data Model in the Raw




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features
    Ultimately, just a pretty face on the XML




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features
    Ultimately, just a pretty face on the XML
• Need to have a basic understanding of the XML




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features
    Ultimately, just a pretty face on the XML
• Need to have a basic understanding of the XML
    Sometimes have to manipulate the XML directly




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features
    Ultimately, just a pretty face on the XML
• Need to have a basic understanding of the XML
    Sometimes have to manipulate the XML directly
• Can use any text editor




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features
    Ultimately, just a pretty face on the XML
• Need to have a basic understanding of the XML
    Sometimes have to manipulate the XML directly
• Can use any text editor
    But Visual Studio XML editor provides color-coding, well-
     formedness checks, and Intellisense



                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Entity Data Model in the Raw
• Designer is a graphical view only of the conceptual
  model
    Exposes most, but not all, features
    Ultimately, just a pretty face on the XML
• Need to have a basic understanding of the XML
    Sometimes have to manipulate the XML directly
• Can use any text editor
    But Visual Studio XML editor provides color-coding, well-
     formedness checks, and Intellisense
• Can’t have open in designer and XML simultaneously

                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
XML Definition Languages




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
XML Definition Languages
• One for each model:




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
XML Definition Languages
• One for each model:
   Conceptual model uses Conceptual Schema Definition
    Language (CSDL)




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
XML Definition Languages
• One for each model:
   Conceptual model uses Conceptual Schema Definition
    Language (CSDL)
   Storage model uses Store Schema Definition
    Language (SSDL)




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
XML Definition Languages
• One for each model:
   Conceptual model uses Conceptual Schema Definition
    Language (CSDL)
   Storage model uses Store Schema Definition
    Language (SSDL)
   Mapping model uses Mapping Specification Language
    (MSL)




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
XML Definition Languages
• One for each model:
   Conceptual model uses Conceptual Schema Definition
    Language (CSDL)
   Storage model uses Store Schema Definition
    Language (SSDL)
   Mapping model uses Mapping Specification Language
    (MSL)
• Visual Studio includes XML schema files



              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Model Build Mechanics




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
   Plus support for the graphical designer




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:
    Conceptual model to .csdl file




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:
    Conceptual model to .csdl file
    Storage model to .ssdl file




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:
    Conceptual model to .csdl file
    Storage model to .ssdl file
    Mapping model to .msl file




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:
    Conceptual model to .csdl file
    Storage model to .ssdl file
    Mapping model to .msl file
• By default, stored in project assembly



                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:
    Conceptual model to .csdl file
    Storage model to .ssdl file
    Mapping model to .msl file
• By default, stored in project assembly
    Can output three physical files



                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Model Build Mechanics
• .edmx file contains XML for all three models
    Plus support for the graphical designer
• Saves as three files at build:
    Conceptual model to .csdl file
    Storage model to .ssdl file
    Mapping model to .msl file
• By default, stored in project assembly
    Can output three physical files
    Change the MetadataArtifactProcessing property of
     the entity container
                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Agenda




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction




             Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda
• Introduction
• Creating and Using an Entity Data Model
• Entity Data Model in the Raw




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Agenda
•   Introduction
•   Creating and Using an Entity Data Model
•   Entity Data Model in the Raw
•   Using Stored Procedures in the Model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application
   Dynamic SQL complicates the job




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application
   Dynamic SQL complicates the job
• Stored procedures vs. dynamic code




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application
   Dynamic SQL complicates the job
• Stored procedures vs. dynamic code




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application
   Dynamic SQL complicates the job
• Stored procedures vs. dynamic code
   Pick one or the other and go for it



               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application
   Dynamic SQL complicates the job
• Stored procedures vs. dynamic code
   Pick one or the other and go for it
• Entity Framework does both well

               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures in the
Model
• Entity Framework can automatically generate all
  code needed to do CRUD
• Not necessarily ideal from DBA’s perspective
   Job is to make sure data is secure, performs well, is
    scalable, and meets needs of the application
   Dynamic SQL complicates the job
• Stored procedures vs. dynamic code
   Pick one or the other and go for it
• Entity Framework does both well
   Current version generates good code, mostly
               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Ways to Use Stored Procedures




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Ways to Use Stored Procedures
• Few different ways




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Ways to Use Stored Procedures
• Few different ways
   Replace an entity’s insert, update, and delete
    functions to use stored procedures




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Ways to Use Stored Procedures
• Few different ways
   Replace an entity’s insert, update, and delete
    functions to use stored procedures
   Use stored procedures that return data to entities are
    scalar values




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Ways to Use Stored Procedures
• Few different ways
   Replace an entity’s insert, update, and delete
    functions to use stored procedures
   Use stored procedures that return data to entities are
    scalar values
• Entity Framework uses terms stored procedure
  and function interchangeably




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Updating the Model from the
Database




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views
• Entity Framework supports updating the model from
  the database




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views
• Entity Framework supports updating the model from
  the database
• Will use several stored procedures




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views
• Entity Framework supports updating the model from
  the database
• Will use several stored procedures
    InsertCustomer, UpdateCustomer, and DeleteCustomer




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views
• Entity Framework supports updating the model from
  the database
• Will use several stored procedures
    InsertCustomer, UpdateCustomer, and DeleteCustomer
    GetCustomersByRegion




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views
• Entity Framework supports updating the model from
  the database
• Will use several stored procedures
    InsertCustomer, UpdateCustomer, and DeleteCustomer
    GetCustomersByRegion
    GetProductListByCategory



                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Updating the Model from the
Database
• Have to include stored procedures in the model
  before you can use them
    Only imported tables and views
• Entity Framework supports updating the model from
  the database
• Will use several stored procedures
      InsertCustomer, UpdateCustomer, and DeleteCustomer
      GetCustomersByRegion
      GetProductListByCategory
      GetProductCategoryAveragePrice

                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures to
Change an Entity




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using Stored Procedures to
Change an Entity
• One of the most common ways to use stored
  procedures




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Using Stored Procedures to
Change an Entity
• One of the most common ways to use stored
  procedures
• Replaces Entity Framework default behavior for
  an entity




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Using Stored Procedures to
Change an Entity
• One of the most common ways to use stored
  procedures
• Replaces Entity Framework default behavior for
  an entity
• Will use the Customer object




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object
    Random sets of data




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object
    Random sets of data
• GetCustomersByRegion returns all of the fields of
  the Customer table




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object
    Random sets of data
• GetCustomersByRegion returns all of the fields of
  the Customer table
• GetProductListByCategory returns fields from the
  Product and ProductCategory tables




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object
    Random sets of data
• GetCustomersByRegion returns all of the fields of
  the Customer table
• GetProductListByCategory returns fields from the
  Product and ProductCategory tables
• Complex type



                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object
    Random sets of data
• GetCustomersByRegion returns all of the fields of
  the Customer table
• GetProductListByCategory returns fields from the
  Product and ProductCategory tables
• Complex type
    Neither an entity or scalar type



                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Read Data
• Use stored procedures that read data in the model
    Materialize an entity object
    Random sets of data
• GetCustomersByRegion returns all of the fields of
  the Customer table
• GetProductListByCategory returns fields from the
  Product and ProductCategory tables
• Complex type
    Neither an entity or scalar type
    Use Model Browser to work with

                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Using Stored Procedures that
Return a Scalar Value




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using Stored Procedures that
Return a Scalar Value
• Another option is to retrieve a scalar value from
  a stored procedure




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Using Stored Procedures that
Return a Scalar Value
• Another option is to retrieve a scalar value from
  a stored procedure
• Dirty little secret




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Using Stored Procedures that
Return a Scalar Value
• Another option is to retrieve a scalar value from
  a stored procedure
• Dirty little secret
   Stored procedure still returns a result set




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Using Stored Procedures that
Return a Scalar Value
• Another option is to retrieve a scalar value from
  a stored procedure
• Dirty little secret
   Stored procedure still returns a result set
   Entity Framework extracts the value, sort of




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Learn More!




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!


• Learn more about Entity Framework on
  SlideShare:




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!


• Learn more about Entity Framework on
  SlideShare:
   Introducing the Entity Framework




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company

More Related Content

PPTX
Entity Framework - Entity Data Model (edm)
PPTX
Linq to entity
PPT
Linq e Ef
PPTX
LINQ for absolute beginners
PPT
B_110500002
PPT
20130329 introduction to linq
PPT
Ling to SQL and Entity Framework performance analysis
PPTX
Entity Framework - Entity Data Model (edm)
Linq to entity
Linq e Ef
LINQ for absolute beginners
B_110500002
20130329 introduction to linq
Ling to SQL and Entity Framework performance analysis

Viewers also liked (20)

PPT
Linq intro
PPTX
Entity Framework - Queries
PPTX
Entity framework
PPTX
LINQ and LINQPad
PPTX
PostCss
PPTX
Think in linq
PPTX
メタプログラミング C#
PDF
The Zachman Framework Unlocked
PPTX
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
PPTX
LINQ in C#
PPT
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
PPTX
Zachman Framework graphics v3.0
PPT
PPT
Of Lambdas and LINQ
PPTX
Advanced C#. Part 2
PPTX
Linq
PDF
How to read a data model
PPSX
Zachman framework
Linq intro
Entity Framework - Queries
Entity framework
LINQ and LINQPad
PostCss
Think in linq
メタプログラミング C#
The Zachman Framework Unlocked
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
LINQ in C#
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
Zachman Framework graphics v3.0
Of Lambdas and LINQ
Advanced C#. Part 2
Linq
How to read a data model
Zachman framework
Ad

Similar to The Entity Data Model (20)

KEY
SharePoint Document Management
KEY
WPF Binding
KEY
What's new in Silverlight 5
KEY
Introducing the Entity Framework
KEY
WPF: Working with Data
KEY
Object-Oriented JavaScript
KEY
Using The .NET Framework
KEY
Managing site collections
KEY
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
KEY
Bring a Web Page Alive with jQuery
KEY
.NET Variables and Data Types
KEY
Object oriented techniques
KEY
Introduction to ASP.NET MVC
KEY
Introducing LINQ
KEY
Sql 2012 development and programming
KEY
Web API HTTP Pipeline
KEY
Web API Basics
KEY
SQL Server: Security
PPT
Alfresco content model
PPT
New in the Visual Studio 2012 IDE
SharePoint Document Management
WPF Binding
What's new in Silverlight 5
Introducing the Entity Framework
WPF: Working with Data
Object-Oriented JavaScript
Using The .NET Framework
Managing site collections
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Bring a Web Page Alive with jQuery
.NET Variables and Data Types
Object oriented techniques
Introduction to ASP.NET MVC
Introducing LINQ
Sql 2012 development and programming
Web API HTTP Pipeline
Web API Basics
SQL Server: Security
Alfresco content model
New in the Visual Studio 2012 IDE
Ad

More from LearnNowOnline (12)

PPT
Windows 8: Shapes and Geometries
PPT
SQL: Permissions and Data Protection
KEY
Attributes, reflection, and dynamic programming
KEY
Asynchronous Programming
KEY
A tour of SQL Server
KEY
Generics
KEY
SharePoint: Introduction to InfoPath
KEY
KnockOutJS with ASP.NET MVC
KEY
Expression Blend Motion & Interaction Design
KEY
Working with Controllers and Actions in MVC
KEY
Creating a User Interface
KEY
.Net branching and flow control
Windows 8: Shapes and Geometries
SQL: Permissions and Data Protection
Attributes, reflection, and dynamic programming
Asynchronous Programming
A tour of SQL Server
Generics
SharePoint: Introduction to InfoPath
KnockOutJS with ASP.NET MVC
Expression Blend Motion & Interaction Design
Working with Controllers and Actions in MVC
Creating a User Interface
.Net branching and flow control

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

The Entity Data Model

  • 1. The Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3. Objectives • Learn how to create and use an Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4. Objectives • Learn how to create and use an Entity Data Model • Explore the raw XML behind the model as a way to understand how Entity Framework works Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5. Objectives • Learn how to create and use an Entity Data Model • Explore the raw XML behind the model as a way to understand how Entity Framework works • See how to use stored procedures within an Entity Framework model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7. Agenda • Introduction Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8. Agenda • Introduction • Creating and Using an Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw • Using Stored Procedures in the Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11. Introduction Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12. Introduction • Key link between entity objects and data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13. Introduction • Key link between entity objects and data  Conceptual model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14. Introduction • Key link between entity objects and data  Conceptual model  Storage model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15. Introduction • Key link between entity objects and data  Conceptual model  Storage model  Mapping model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16. Introduction • Key link between entity objects and data  Conceptual model  Storage model  Mapping model • Application design is often at odds with database design Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17. Introduction • Key link between entity objects and data  Conceptual model  Storage model  Mapping model • Application design is often at odds with database design • Can work with model in designer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18. Introduction • Key link between entity objects and data  Conceptual model  Storage model  Mapping model • Application design is often at odds with database design • Can work with model in designer  Or get messy with the XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 19. Introduction • Key link between entity objects and data  Conceptual model  Storage model  Mapping model • Application design is often at odds with database design • Can work with model in designer  Or get messy with the XML • At build, split into three XML files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20. Introduction • Key link between entity objects and data  Conceptual model  Storage model  Mapping model • Application design is often at odds with database design • Can work with model in designer  Or get messy with the XML • At build, split into three XML files • Developers don’t have to know the database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21. The Models within the Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22. The Models within the Model • Conceptual Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23. The Models within the Model • Conceptual Model  The actual Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model  Represents the database schemas Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 27. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model  Represents the database schemas  Can be similar to conceptual model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 28. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model  Represents the database schemas  Can be similar to conceptual model  Decupling of conceptual design from the database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 29. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model  Represents the database schemas  Can be similar to conceptual model  Decupling of conceptual design from the database • Mapping Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 30. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model  Represents the database schemas  Can be similar to conceptual model  Decupling of conceptual design from the database • Mapping Model  Bridge between conceptual and storage models Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 31. The Models within the Model • Conceptual Model  The actual Entity Data Model  Provides what is needed to create data objects • Storage Model  Represents the database schemas  Can be similar to conceptual model  Decupling of conceptual design from the database • Mapping Model  Bridge between conceptual and storage models  Map object properties to database fields Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 32. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 33. Agenda • Introduction Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 34. Agenda • Introduction • Creating and Using an Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 35. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 36. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw • Using Stored Procedures in the Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 37. Creating and Using an Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 38. Creating and Using an Entity Data Model • Can create from scratch using XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 39. Creating and Using an Entity Data Model • Can create from scratch using XML  More productive using the designer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 40. Creating and Using an Entity Data Model • Can create from scratch using XML  More productive using the designer • Three approaches Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 41. Creating and Using an Entity Data Model • Can create from scratch using XML  More productive using the designer • Three approaches  Database-first Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 42. Creating and Using an Entity Data Model • Can create from scratch using XML  More productive using the designer • Three approaches  Database-first  Model-first Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 43. Creating and Using an Entity Data Model • Can create from scratch using XML  More productive using the designer • Three approaches  Database-first  Model-first  Code-first Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 44. Creating a Model Using Database- First Design Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 45. Creating a Model Using Database- First Design • Directly supported by the Entity Framework template Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 46. Creating a Model Using Database- First Design • Directly supported by the Entity Framework template • Wizard lets you Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 47. Creating a Model Using Database- First Design • Directly supported by the Entity Framework template • Wizard lets you  Reverse-engineer the database schma Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 48. Creating a Model Using Database- First Design • Directly supported by the Entity Framework template • Wizard lets you  Reverse-engineer the database schma  Select tables, views, and stored procedures to include Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 49. Creating a Model Using Database- First Design • Directly supported by the Entity Framework template • Wizard lets you  Reverse-engineer the database schma  Select tables, views, and stored procedures to include  Build the model from selected objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 50. Multiplicity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 51. Multiplicity • Used with associations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 52. Multiplicity • Used with associations • Number of entities that can be on each end of an association Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 53. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 54. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 55. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 56. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1  Zero or one: 0..1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 57. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1  Zero or one: 0..1  Many: * Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 58. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1  Zero or one: 0..1  Many: * • Can combine in various ways, such as Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 59. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1  Zero or one: 0..1  Many: * • Can combine in various ways, such as  1:* Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 60. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1  Zero or one: 0..1  Many: * • Can combine in various ways, such as  1:*  0..1:* Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 61. Multiplicity • Used with associations • Number of entities that can be on each end of an association  Sometimes referred to as cardinality • Three options  One: 1  Zero or one: 0..1  Many: * • Can combine in various ways, such as  1:*  0..1:*  *:* Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 62. Entity Data Model Object Properties Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 63. Entity Data Model Object Properties • Typical for Visual Studio Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 64. Entity Data Model Object Properties • Typical for Visual Studio • Use Properties windows to set values of properties for various objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 65. Entity Data Model Object Properties • Typical for Visual Studio • Use Properties windows to set values of properties for various objects • Model stores some in model’s XML to define a model, others guide object creation Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 66. Creating a Model Using Model-First Design Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 67. Creating a Model Using Model-First Design • Database-first design is common Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 68. Creating a Model Using Model-First Design • Database-first design is common • Sometimes creating a new database with the application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 69. Creating a Model Using Model-First Design • Database-first design is common • Sometimes creating a new database with the application  Could create the database first Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 70. Creating a Model Using Model-First Design • Database-first design is common • Sometimes creating a new database with the application  Could create the database first  But model-first is another option Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 71. Creating a Model Using Model-First Design • Database-first design is common • Sometimes creating a new database with the application  Could create the database first  But model-first is another option  Strictly speaking, Entity Framework has always had this option Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 72. Creating a Model Using Model-First Design • Database-first design is common • Sometimes creating a new database with the application  Could create the database first  But model-first is another option  Strictly speaking, Entity Framework has always had this option • Generate Database from Model option Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 73. Creating a Model Using Model-First Design • Database-first design is common • Sometimes creating a new database with the application  Could create the database first  But model-first is another option  Strictly speaking, Entity Framework has always had this option • Generate Database from Model option • Entity Designer Database Generation Power Pack Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 74. Sled Dog Event Registration Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 75. Sled Dog Event Registration Team Event Race FirstName Name 1 * 1 * Distance LastName EventDate DogCount City Sponsor Trail Country Location DogCount Mushing Skijoring Leader1 Dog1 Leader2 Dog2 Dog3 NumberOfLeaders Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 76. Explore the Model with the Model Browser Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 77. Explore the Model with the Model Browser • Working with large models can be hard in the designer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 78. Explore the Model with the Model Browser • Working with large models can be hard in the designer  Can be hard to understand the structure of the model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 79. Explore the Model with the Model Browser • Working with large models can be hard in the designer  Can be hard to understand the structure of the model  Mapping Details windows doesn’t have details of storage model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 80. Explore the Model with the Model Browser • Working with large models can be hard in the designer  Can be hard to understand the structure of the model  Mapping Details windows doesn’t have details of storage model • Overcome these limitations with the Model Browser Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 81. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 82. Agenda • Introduction Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 83. Agenda • Introduction • Creating and Using an Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 84. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 85. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw • Using Stored Procedures in the Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 86. Entity Data Model in the Raw Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 87. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 88. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 89. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features  Ultimately, just a pretty face on the XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 90. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features  Ultimately, just a pretty face on the XML • Need to have a basic understanding of the XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 91. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features  Ultimately, just a pretty face on the XML • Need to have a basic understanding of the XML  Sometimes have to manipulate the XML directly Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 92. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features  Ultimately, just a pretty face on the XML • Need to have a basic understanding of the XML  Sometimes have to manipulate the XML directly • Can use any text editor Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 93. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features  Ultimately, just a pretty face on the XML • Need to have a basic understanding of the XML  Sometimes have to manipulate the XML directly • Can use any text editor  But Visual Studio XML editor provides color-coding, well- formedness checks, and Intellisense Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 94. Entity Data Model in the Raw • Designer is a graphical view only of the conceptual model  Exposes most, but not all, features  Ultimately, just a pretty face on the XML • Need to have a basic understanding of the XML  Sometimes have to manipulate the XML directly • Can use any text editor  But Visual Studio XML editor provides color-coding, well- formedness checks, and Intellisense • Can’t have open in designer and XML simultaneously Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 95. XML Definition Languages Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 96. XML Definition Languages • One for each model: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 97. XML Definition Languages • One for each model:  Conceptual model uses Conceptual Schema Definition Language (CSDL) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 98. XML Definition Languages • One for each model:  Conceptual model uses Conceptual Schema Definition Language (CSDL)  Storage model uses Store Schema Definition Language (SSDL) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 99. XML Definition Languages • One for each model:  Conceptual model uses Conceptual Schema Definition Language (CSDL)  Storage model uses Store Schema Definition Language (SSDL)  Mapping model uses Mapping Specification Language (MSL) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 100. XML Definition Languages • One for each model:  Conceptual model uses Conceptual Schema Definition Language (CSDL)  Storage model uses Store Schema Definition Language (SSDL)  Mapping model uses Mapping Specification Language (MSL) • Visual Studio includes XML schema files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 101. Model Build Mechanics Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 102. Model Build Mechanics • .edmx file contains XML for all three models Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 103. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 104. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 105. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build:  Conceptual model to .csdl file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 106. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build:  Conceptual model to .csdl file  Storage model to .ssdl file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 107. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build:  Conceptual model to .csdl file  Storage model to .ssdl file  Mapping model to .msl file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 108. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build:  Conceptual model to .csdl file  Storage model to .ssdl file  Mapping model to .msl file • By default, stored in project assembly Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 109. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build:  Conceptual model to .csdl file  Storage model to .ssdl file  Mapping model to .msl file • By default, stored in project assembly  Can output three physical files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 110. Model Build Mechanics • .edmx file contains XML for all three models  Plus support for the graphical designer • Saves as three files at build:  Conceptual model to .csdl file  Storage model to .ssdl file  Mapping model to .msl file • By default, stored in project assembly  Can output three physical files  Change the MetadataArtifactProcessing property of the entity container Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 111. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 112. Agenda • Introduction Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 113. Agenda • Introduction • Creating and Using an Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 114. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 115. Agenda • Introduction • Creating and Using an Entity Data Model • Entity Data Model in the Raw • Using Stored Procedures in the Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 116. Using Stored Procedures in the Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 117. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 118. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 119. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 120. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application  Dynamic SQL complicates the job Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 121. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application  Dynamic SQL complicates the job • Stored procedures vs. dynamic code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 122. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application  Dynamic SQL complicates the job • Stored procedures vs. dynamic code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 123. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application  Dynamic SQL complicates the job • Stored procedures vs. dynamic code  Pick one or the other and go for it Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 124. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application  Dynamic SQL complicates the job • Stored procedures vs. dynamic code  Pick one or the other and go for it • Entity Framework does both well Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 125. Using Stored Procedures in the Model • Entity Framework can automatically generate all code needed to do CRUD • Not necessarily ideal from DBA’s perspective  Job is to make sure data is secure, performs well, is scalable, and meets needs of the application  Dynamic SQL complicates the job • Stored procedures vs. dynamic code  Pick one or the other and go for it • Entity Framework does both well  Current version generates good code, mostly Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 126. Ways to Use Stored Procedures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 127. Ways to Use Stored Procedures • Few different ways Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 128. Ways to Use Stored Procedures • Few different ways  Replace an entity’s insert, update, and delete functions to use stored procedures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 129. Ways to Use Stored Procedures • Few different ways  Replace an entity’s insert, update, and delete functions to use stored procedures  Use stored procedures that return data to entities are scalar values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 130. Ways to Use Stored Procedures • Few different ways  Replace an entity’s insert, update, and delete functions to use stored procedures  Use stored procedures that return data to entities are scalar values • Entity Framework uses terms stored procedure and function interchangeably Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 131. Updating the Model from the Database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 132. Updating the Model from the Database • Have to include stored procedures in the model before you can use them Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 133. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 134. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views • Entity Framework supports updating the model from the database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 135. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views • Entity Framework supports updating the model from the database • Will use several stored procedures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 136. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views • Entity Framework supports updating the model from the database • Will use several stored procedures  InsertCustomer, UpdateCustomer, and DeleteCustomer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 137. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views • Entity Framework supports updating the model from the database • Will use several stored procedures  InsertCustomer, UpdateCustomer, and DeleteCustomer  GetCustomersByRegion Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 138. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views • Entity Framework supports updating the model from the database • Will use several stored procedures  InsertCustomer, UpdateCustomer, and DeleteCustomer  GetCustomersByRegion  GetProductListByCategory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 139. Updating the Model from the Database • Have to include stored procedures in the model before you can use them  Only imported tables and views • Entity Framework supports updating the model from the database • Will use several stored procedures  InsertCustomer, UpdateCustomer, and DeleteCustomer  GetCustomersByRegion  GetProductListByCategory  GetProductCategoryAveragePrice Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 140. Using Stored Procedures to Change an Entity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 141. Using Stored Procedures to Change an Entity • One of the most common ways to use stored procedures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 142. Using Stored Procedures to Change an Entity • One of the most common ways to use stored procedures • Replaces Entity Framework default behavior for an entity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 143. Using Stored Procedures to Change an Entity • One of the most common ways to use stored procedures • Replaces Entity Framework default behavior for an entity • Will use the Customer object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 144. Using Stored Procedures that Read Data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 145. Using Stored Procedures that Read Data • Use stored procedures that read data in the model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 146. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 147. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object  Random sets of data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 148. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object  Random sets of data • GetCustomersByRegion returns all of the fields of the Customer table Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 149. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object  Random sets of data • GetCustomersByRegion returns all of the fields of the Customer table • GetProductListByCategory returns fields from the Product and ProductCategory tables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 150. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object  Random sets of data • GetCustomersByRegion returns all of the fields of the Customer table • GetProductListByCategory returns fields from the Product and ProductCategory tables • Complex type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 151. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object  Random sets of data • GetCustomersByRegion returns all of the fields of the Customer table • GetProductListByCategory returns fields from the Product and ProductCategory tables • Complex type  Neither an entity or scalar type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 152. Using Stored Procedures that Read Data • Use stored procedures that read data in the model  Materialize an entity object  Random sets of data • GetCustomersByRegion returns all of the fields of the Customer table • GetProductListByCategory returns fields from the Product and ProductCategory tables • Complex type  Neither an entity or scalar type  Use Model Browser to work with Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 153. Using Stored Procedures that Return a Scalar Value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 154. Using Stored Procedures that Return a Scalar Value • Another option is to retrieve a scalar value from a stored procedure Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 155. Using Stored Procedures that Return a Scalar Value • Another option is to retrieve a scalar value from a stored procedure • Dirty little secret Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 156. Using Stored Procedures that Return a Scalar Value • Another option is to retrieve a scalar value from a stored procedure • Dirty little secret  Stored procedure still returns a result set Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 157. Using Stored Procedures that Return a Scalar Value • Another option is to retrieve a scalar value from a stored procedure • Dirty little secret  Stored procedure still returns a result set  Entity Framework extracts the value, sort of Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 158. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 159. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 160. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 161. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about Entity Framework on SlideShare: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 162. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about Entity Framework on SlideShare:  Introducing the Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

Editor's Notes