Entity Framework Overview

4,639 views

Published on

Entity Framework Overview

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,639
On SlideShare
0
From Embeds
0
Number of Embeds
1,621
Actions
Shares
0
Downloads
83
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Entity Framework Overview

  1. 1. Entity Framework<br />Eyal Vardi<br />CEO E4D Solutions LTDMicrosoft MVP Visual C#blog: www.eVardi.com<br />
  2. 2. Agenda<br />Data Access History<br />OO vs. Relational World<br />EF Architecture<br />Development Approaches<br />EF 4.0+ New API<br />EDM<br />LINQ to Entities<br />Entity SQL<br />Conceptual Model<br />Object Services<br />Mapping<br />Entity Client Provider<br />StorageModel<br />ADO.NET Provider<br />
  3. 3. Data Access History<br />
  4. 4. Services:- Change tracking- Concurrency control- Object identity<br />SQL or Stored Procs<br />Rows<br />SQLServer<br />Entity Framework<br />Entity Framework Flow<br />Application<br />from c in db.Customerswhere c.City == "London"select new { c.Name, c.Phone }<br />Objects<br />LINQ Query<br />SubmitChanges()<br />EDMX<br />ADO.NET Provider<br />SQL Query<br />select Name, Phonefrom customerswhere city = 'London'<br />
  5. 5. OO vs. Relational World<br />Data Types<br />Associations<br />Granularity<br />Inheritance<br />Identity<br />
  6. 6. EF Architecture<br />SQLServer<br />EDM<br />LINQ to Entities<br />Entity SQL<br />Conceptual Model<br />Object Services<br />Mapping<br />Entity Client Provider<br />StorageModel<br />ADO.NET Provider<br />
  7. 7. Entity Data Model (EDM)<br />The EDM is the link between the model and the database.<br />The EDM is that it decouples your application from the underlying store.<br />Entity Data Model (EDM)<br />StorageModel<br />(SSDL)<br />Mapping<br />(MSL)<br />Conceptual Model (CSDL)<br />Storage<br />
  8. 8. Object Services<br />Materialization <br />The process of transforming the data obtained from the Entity Client data provider, which has a tabular structure, into objects. <br />Change tracking <br />Tracks any changes made to the objects.<br />Query transformation<br />Translates queries it into a command tree that’s then passed on to the underlying Entity Client.<br /><ul><li>Object identities</li></li></ul><li>Object Services Functions<br />Querying<br />Querying data as objects <br />Shaping query results <br />Composing queries<br />CRUD <br />Lazy loading<br />Inheritance<br />Navigating relationship<br />Change tracking <br />Saving changes<br />Attaching objects<br />Detaching objects <br />Serializing objects<br />Managing<br />Object identities<br />Concurrency<br />Transactions<br />
  9. 9. Entity SQL & LINQ to Entities<br />LINQ to Entities - The LINQ dialect that enables typed queries against the model.<br />Entity SQL - The second way of querying the object model.<br />Entity SQL is string-based.<br />Can be used to retrieve data at low level, directly using the Entity Client.<br />
  10. 10. EDM<br />LINQ to Entities<br />Entity SQL<br />Conceptual Model<br />Development Approaches<br />Object Services<br />Mapping<br />Entity Client Provider<br />StorageModel<br />ADO.NET Provider<br />
  11. 11. Database First<br />DB<br />If you already have a database, the Entity Framework can automatically generate a data model that consists of classes and properties that correspond to existing database objects such as tables and columns. <br />Generated<br />Data Model<br />(.edmx)<br />Database First<br />
  12. 12. Model First<br />Generated<br />DB<br />If you don't yet have a database, you can begin by creating a model using the Entity Framework designer in Visual Studio. <br />The designer can generate DDL (data definition language) statements to create the database. <br />Data Model<br />(.edmx)<br />Model First<br />
  13. 13. DB<br />Generated<br />Data Model<br />(Classes)<br />Code First<br />Code First<br />Generated<br />DB<br />Whether you have an existing database or not, you can code your own classes and properties that correspond to tables and columns and use them with the Entity Framework without an .edmx file.<br />Data Model<br />(Classes)<br />Code First<br />
  14. 14. Why DbContext & DbSet?<br />This API provides a more productive surface for working with the EF and can be used with the Code First, Database First, and Model First approaches.<br />Model Discovery<br />Model Caching<br />DbSet Initialization<br />Database Provisioning<br />DbModelConstructor<br />ObjectContextConstructor<br />* More info click here<br />
  15. 15. EF 4.1 New API<br />
  16. 16. Features That Are Not Supported<br />features are not supported by the DbContextAPI. To use these features, use the ObjectContextAPI.<br />Compiled queries<br />MEST (Multiple Entity Sets per Type)<br />Self-tracking entities. <br />To use the DbContext API in an N-tier application, consider using WCF Data Services or RIA Services.<br />

×