entity framework

of 33 /33
MD. SAIFULLAH AL AZAD, Software Architect LEADS Corporation Limited 6/17/22 ADO.NET ENTITY FRAMEWORK You found me in internet: Blog: LinkedIn: http:// Facebook: https://

Author: ayasha

Post on 25-Feb-2016




0 download

Embed Size (px)


MD. SAIFULLAH AL AZAD, Software Architect . ADO.NET Entity Framework. LEADS Corporation Limited. You found me in internet: Blog: LinkedIn: http:// Facebook : https:// What Is It?. - PowerPoint PPT Presentation


ADO.NET Entity Framework

MD. SAIFULLAH AL AZAD, Software Architect

LEADS Corporation Limited

May 15, 2013ADO.NET Entity FrameworkYou found me in internet:Blog: LinkedIn: Facebook: 1What Is It?The ADO.NET Entity Framework is part of Microsofts next generation of .NET technologies.It is intended to make it easier and more effective for object-oriented applications to work with data.



Visual StudioQuadrantSQL Server Modeling ServicesEntity FrameworkADO.NET M/EDMData Services


3The Logical Data ModelAlmost 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.

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

The ResultThe 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.

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

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

Why the Entity Model?Closer to the application problem spaceBetter suited for object oriented programmingSupports InheritanceSupports complex typesRelationships are more meaningful to the application

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

Entity Data ModelA gob of XML that definesLogical Data Tables, Views, Foreign KeysEntity Objects that Map to the Logical DataThe Mapping Between the Two

Entity Data Model DesignerA Visual Studio Designer that protects developers from the XML that is the EDM

ObjectContextA code-generated data context created from the Entity Data ModelResponsible for managing communication between the conceptual data model and the logical data model

EntitiesCode-generated class definitions for objects defined in the EDM.

Getting the Data OutHow do we get data out of the fancy Entity Data Model?

eSQL (Entity SQL)A brand new SQL language to learnLeverages the rich, object-oriented Entity Data Model InheritanceCollectionsComplex TypesLiteral Strings No Compiler CheckingQuestionable value in embedded SQL in code

Extensions Methods and String PredicatesQueries the object model created against the EDMStill string-based. No compiler checkingAn ugly mix of code and eSQL statements

LINQ to EntitiesFull compiler checking. No wondering if the query is valid.A fun new SQL-Like syntaxMore OO-ish

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

Combine Multiple Logical Tables into One EntityDatabase TablesEntity Data Model

Implement InheritanceDatabase TablesEntity Data Model

Other Fun StuffImplement Complex Types (e.g. Address)Consume Conceptual Model with Reporting Services and other BI ToolsCreate an EDM that talks to stored proceduresUse transactions, manage concurrency, cache execution plans

Manipulate Data By Manipulating ObjectsDatabase Result DesiredEDM Object ManipulationINSERT ROWCreate new objectAdd object to EDM ContextUpdate ContextDELETE ROWGet instance of object from EDM ContextAsk Context to remove the objectUpdate ContextUPDATE ROWGet instance of object from EDM ContextUpdate objectUpdate Context

New in ADO.NET Entity Framework 4.0

Model-first developmentAutomatic pluralizationForeign keys in modelsPOCO class supportLazy loadingT4 Code GenerationTemplate customizationIObjectSetVirtual SaveChangesObjectStateManager controlSelf-tracking entitiesSQL generation improvementsMore LINQ operator supportLINQ extensibilityExecuteStoreQueryExecuteStoreCommandSPROC import improvementsModel defined functionsWPF designer integrationCode-Only development (Feature CTP)App CodeCustomersADO.NETProvidersSQL ServerOracle...DataReaderCustomersOracleCommandExecuteProvider Specific (PL/SQL)SELECT * FROM CUSTOMERSCustomersADO.NET Today

CustomersConceptual ModelUKCustomerUKPremiumCustomerMapADO.NET Entity Framework

App CodeCustomersADO.NETProviders*SQL ServerOracle...OracleEntityProviderDataReaderUKCustomerCommandExecuteConceptual ModelUKCustomerUKPremiumCustomerMapProvider Agnostic (ESQL)SELECT * FROM UKCUSTOMERUKCustomerADO.NET Entity Framework

.NET Entity Provider (Entity SQL)CommandConnectionReaderEFStore.NET Data ProviderV2.0CommandConnectionReaderAdapterEFConceptual ModelEntityEntityrelationshipStore Model(SSDL)Entity Data Model(CSDL)Mapping (MSL)EFProgramming ModelObject Relational MappingLINQADO.NET Entity Framework

StoreGood CustomersIDFirstNameLastNameBad CustomersIDForeNameSurnameCustomersCustomerIdFirstLastTypeEntitiesMappingType=GType=BMapping Examples ( 1 Splitting )

StoreCustomerCustomerIdFirstLastEntitiesMappingCustomersIDFirstNameLastNameIsPremiumOverdraftAccountManagerPremiumCustomerOverdraftAccountManager?* Framework also supports TPTMapping Examples ( 2 TPH )

StoreUkCustomerCustomerIdNameEntitiesMappingClientView1select, c.namefrom customers cwhere = UKp_DeleteUkCustomerp_UpdateUkCustomerp_InsertUkCustomerMapping Examples ( 3 View + SPs )

Any Question