1 / 33

ADO.NET Entity Framework

MD. SAIFULLAH AL AZAD, Software Architect . ADO.NET Entity Framework. LEADS Corporation Limited. You found me in internet: Blog: www.dotnetbd.wordpress.com LinkedIn: http:// bd.linkedin.com/pub/saifullah-azad/69/604/7a8 Facebook : https:// www.facebook.com/saifullah.azad. What Is It?.

ayasha
Télécharger la présentation

ADO.NET Entity Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MD. SAIFULLAH AL AZAD, Software Architect ADO.NET Entity Framework LEADS Corporation Limited You found me in internet: Blog: www.dotnetbd.wordpress.com LinkedIn: http://bd.linkedin.com/pub/saifullah-azad/69/604/7a8 Facebook: https://www.facebook.com/saifullah.azad

  2. What Is It? • The ADO.NET Entity Framework is part of Microsoft’s next generation of .NET technologies. • It is intended to make it easier and more effective for object-oriented applications to work with data.

  3. Architecture Visual Studio “Quadrant” Entity Framework Data Services ADO.NET “M”/EDM SQL Azure SQL Server … SQL Server Modeling Services

  4. The Logical Data Model • Almost any business application today has to speak to a relational database. • This involves the usual suspects of tables with foreign keys, a smattering of views, and generally a gob of stored procedures.

  5. The Object-Oriented Domain Model • Applications themselves are written in a completely different world. • The same data that lives in the relational database is represented entirely differently in the application.

  6. The Result • The result of this “impedance mismatch” is that developers devote a lot of time and energy writing code to translate between how the database likes to see data and how the application likes to see data.

  7. Other Ways to Address The Same Problem • Hibernate (Java) • Enterprise Objects Framework (Mac OS) • NHibernate (.NET) • LINQ to SQL (Visual Studio 2008) • And many, many, more …

  8. The ADO.NET Entity Framework • The ADO.NET Entity Framework seeks to remedy the problem by providing a layer of abstraction between the logical data model and the application domain.

  9. Why the Entity Model? • Closer to the application problem space • Better suited for object oriented programming • Supports Inheritance • Supports complex types • Relationships are more meaningful to the application

  10. The “Stuff” in ADO.NET Entity Framework The tools and technology that developers will interact with when using the ADO.NET Entity Framework

  11. Entity Data Model • A gob of XML that defines • Logical Data Tables, Views, Foreign Keys • Entity Objects that Map to the Logical Data • The Mapping Between the Two

  12. Entity Data Model Designer • A Visual Studio Designer that protects developers from the XML that is the EDM

  13. ObjectContext • A code-generated data context created from the Entity Data Model • Responsible for managing communication between the conceptual data model and the logical data model

  14. Entities • Code-generated class definitions for objects defined in the EDM.

  15. Getting the Data Out How do we get data out of the fancy Entity Data Model?

  16. eSQL (Entity SQL) • A brand new SQL language to learn • Leverages the rich, object-oriented Entity Data Model • Inheritance • Collections • Complex Types • Literal Strings – No Compiler Checking • Questionable value in embedded SQL in code

  17. Extensions Methods and String Predicates • Queries the object model created against the EDM • Still string-based. No compiler checking • An ugly mix of code and eSQL statements

  18. LINQ to Entities • Full compiler checking. No wondering if the query is valid. • A fun new SQL-Like syntax • More OO-ish

  19. What Can You Do? The power of the Entity Data Model contrasted to a logical data model of tables and stored procedures.

  20. Combine Multiple Logical Tables into One Entity Database Tables Entity Data Model

  21. Implement Inheritance Database Tables Entity Data Model

  22. Other Fun Stuff • Implement Complex Types (e.g. Address) • Consume Conceptual Model with Reporting Services and other BI Tools • Create an EDM that talks to stored procedures • Use transactions, manage concurrency, cache execution plans

  23. Manipulate Data By Manipulating Objects

  24. New in ADO.NET Entity Framework 4.0 • Self-tracking entities • SQL generation improvements • More LINQ operator support • LINQ extensibility • ExecuteStoreQuery • ExecuteStoreCommand • SPROC import improvements • Model defined functions • WPF designer integration • Code-Only development (Feature CTP) Model-first development Automatic pluralization Foreign keys in models POCO class support Lazy loading T4 Code Generation Template customization IObjectSet Virtual SaveChanges ObjectStateManagercontrol

  25. Provider Specific (PL/SQL) “SELECT * FROM CUSTOMERS” ADO.NET Today App Code ADO.NET Command Providers Execute SQL Server DataReader Oracle Oracle Customers Customers Customers ...

  26. ADO.NET Entity Framework Conceptual Model Map Customers UKCustomer UKPremiumCustomer

  27. Provider Agnostic (ESQL) “SELECT * FROM UKCUSTOMER” ADO.NET Entity Framework App Code ADO.NET Conceptual Model Map Entity Provider Command Execute DataReader Customers UKPremiumCustomer UKCustomer UKCustomer UKCustomer Providers* SQL Server Oracle Oracle ...

  28. ADO.NET Entity Framework EF EF .NET Entity Provider (Entity SQL) Programming Model EF Entity Data Model (CSDL) Conceptual Model LINQ Reader Connection Command Entity Entity Object Relational Mapping relationship Mapping (MSL) V2.0 Store Model (SSDL) .NET Data Provider Store Reader Connection Adapter Command

  29. Mapping Examples ( 1 – Splitting ) Mapping Store Entities Type=“G” Customers Good Customers CustomerId ID First FirstName Last LastName Type Bad Customers ID ForeName Type=“B” Surname

  30. Mapping Examples ( 2 – TPH ) Store Mapping Entities Customer Customers CustomerId ID First FirstName Last LastName ? IsPremium Overdraft AccountManager PremiumCustomer Overdraft AccountManager * Framework also supports TPT

  31. Mapping Examples ( 3 – View + SPs ) Store Mapping Entities UkCustomer ClientView1 CustomerId select c.id, c.name from customers c where c.country = ‘UK’ Name p_DeleteUkCustomer p_UpdateUkCustomer p_InsertUkCustomer

  32. Any Question

More Related