Getting started with entity framework

7,346 views

Published on

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

No Downloads
Views
Total views
7,346
On SlideShare
0
From Embeds
0
Number of Embeds
808
Actions
Shares
0
Downloads
404
Comments
0
Likes
7
Embeds 0
No embeds

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

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

    ×