Académique Documents
Professionnel Documents
Culture Documents
Objectives
Learn about how object-relational mapping works to provide data access Understand what the Entity Framework is and how it can provide robust data access services to applications See how to build a database-first Entity Data Model using Visual Studio Explore the various Entity Framework APIs and tools
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Agenda
Object-Relational Mapping (ORM) and Data Access The Entity Framework and Data Model Building a Simple Application using Entity Framework Entity Framework APIs and Tools
Just about all applications make use of data Microsoft has a long history of providing data access technologies But they have problems
Too close to the metal Use generic data objects
Data access code is usually a lot of code Differences between objects and database Entity Framework bridges the gap Terminology: data store and database
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Object/Relational Differences
Inherent problems application has to overcome
Needs lots of code somewhere Big impact on application design, effort, and performance
Some have direct equivalents in .NET Database types often have constraints Binary data in the database can be anything Dates and times are another issue
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Relationship Difference
Databases use foreign key constraints .NET objects use object references SalesOrderHeader and SalesOrderDetail tables
Relationship Difference
Many-to-Many relationships In AdventureWorks, customers and addresses
Inheritance Difference
.NET supports object inheritance
No support for multiple inheritance
Identity/Equality Difference
How do you tell two things are the same? Database: identity of a row is the primary key
Enforced by a primary key constraint Can use either natural or surrogate keys
The model is not the database! Generic data objects require lots of code Entity data objects mean querying a schema that reflects business model ORM eliminates context shift in code
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Agenda
Object-Relational Mapping (ORM) and Data Access The Entity Framework and Data Model Building a Simple Application using Entity Framework Entity Framework APIs and Tools
Initial release didnt gain much traction Version 4.1 is a mature product
Substantial commitment and innovation
Version numbers
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
LINQ to SQL
Similar to Entity Framework
Both use LINQ to query a database using a data model
Soon Microsoft had two new data access technologies LINQ to SQL moved, and lost out to Entity Framework
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Agenda
Object-Relational Mapping (ORM) and Data Access The Entity Framework and Data Model Building a Simple Application using Entity Framework Entity Framework APIs and Tools
Agenda
Object-Relational Mapping (ORM) and Data Access The Entity Framework and Data Model Building a Simple Application using Entity Framework Entity Framework APIs and Tools
Architecture
Entity Data Model
Application
Entity SQL Query
Entity SQL Query
Results
Conceptual Model
Mapping Storage Model
Object Services
Command Tree
Entity Data Reader
Data Store
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Neither is necessarily better than the other Entity Framework supports both Provides three ways to build an application
Database-first design Model-first design Code-first design
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Object Services
Manages all of the objects in Entity Framework Key task is to handle differences between database and objects Provides and EntityObject class and manages objects that inherit from it Four primary tasks
Exposes an API Performs query transformations Performs object materialization Tracks state of objects and updates data store
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Entity Client
Communicates with the database and manages data conversions
Must know structure of database as well as entity data objects Uses the full Entity Data Model
Can work with any data store with a provider SQL Server versions Dont have to use Object Services to query
Can use Entity SQL directly to Entity Client
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!