1 / 13

Entity Framework

Entity Framework. James Winters. Agenda. Why? What is it? How do you use it? Where do you get more info?. Is EF just another ORM?. Yes and No  Entity Domain Model is a very flexible Mapper Should allow for mapping to non-relational data, such as OLAP

Samuel
Télécharger la présentation

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. Entity Framework James Winters

  2. Agenda • Why? • What is it? • How do you use it? • Where do you get more info?

  3. Is EF just another ORM? • Yes and No  • Entity Domain Model is a very flexible Mapper • Should allow for mapping to non-relational data, such as OLAP • Out of the box all the samples are ORM • Mapping the database to the domain model is currently all EF tooling does • You can hand craft though • Provides mechanisms to create own Providers • Or more likely to download vendor created providers

  4. Architecture SQL Server Relational DBMS Entity Services Applications Reporting Analysis Programming Layers Search Sync Code Gen Linq to Entities Entity SQL Browsing Binding Entity Client – EDM, Entity SQL Domain Modeling Tools Metadata Services Query and Update Pipelines Mapping Mapping Entity Framework Runtime Transactions Modeling Data Providers (ADO.NET patterns) SqlClient OtherClient Non-relational Web Service

  5. Logical Model Object Model (O – Space) Linq Mapped via Attributes Or IPOCO Conceptual Model (C - Space) ADO. Net Provider e.g.EntityClient Mapped via EDMGen or tools Store Model (S-Space) ADO. Net Provider e.g. SqlClient

  6. How is the model stored • As metadata in XML • 3 files • .CSDL (Conceptual Schema Definition Language) • Maps the entity types that you use in your conceptual model • .SSDL (Store Schema Definition Language) • What the DB looks like • .MSL (Mapping Schema Language) • Maps the CSL to the SSDL • Created by Designer tool • Or use EMDGen • Must be available to the runtime • Copy in to bin folder, or use embedded resource build option

  7. Entity Data Model • Tooling provided in CTP 1 • Will be much improved in CTP 2

  8. Querying • 4 strategies • Use the EntityClient Provider • Query C-Space using ADO.Net techniques and Entity SQL • Query the Object Model • Use ObjectQuery<T> and Entity SQL to create objects • Uses ObjectContext to provide the container • Use the generated container to generate objects • Still data oriented, but less so • Use Linq to Entities • Still not totally persistent ignorant, but best we have till Beta 3

  9. The ObjectContext • Can be thought of as the Object Services manager • Encapsulates the mapping and manages the CRUD • Tracks state via the ObjectStateManager • Switch it off for read only via MergeOptions.NoTracking • Entities have one of 5 states • Added • Deleted • Modified • Unchanged • Detached

  10. Persisting Change • When you call SaveChanges() • ObjectContext calculates CRUD options by examining Entity collection and querying state • Concurrency? • Transactions? • Optimisation?

  11. Stored Procedures • For now you have to provide the function declaration in C-Space • And also the mappings to S-Space • Complex type mappings are also hand cranked for now • Simple 1-1 mappings only • Tools in CTP2 have SP and complex type mapping support

  12. References • My Blog • http://www.wintersfamily.plus.com/blogs/JamesWinters/ • ADO.Net Team Blog • http://blogs.msdn.com/adonet/ • The Entity Framework FAQ • http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx

  13. Summary • Shows great promise • It will be the data access technology of choice • Unless Linq to Hibernate takes off • Tooling needs to improve • Or write your own 

More Related