Entity FrameworkEyal VardiCEO E4D Solutions LTDMicrosoft MVP Visual C#blog: www.eVardi.com
AgendaData Access HistoryOO vs. Relational WorldEF ArchitectureDevelopment ApproachesEF 4.0+ New APIEDMLINQ to EntitiesEntity SQLConceptual ModelObject ServicesMappingEntity Client ProviderStorageModelADO.NET Provider
Data Access History
Services:- Change tracking- Concurrency control- Object identitySQL or Stored ProcsRowsSQLServerEntity FrameworkEntity Framework FlowApplicationfrom c in db.Customerswhere c.City == "London"select new { c.Name, c.Phone }ObjectsLINQ QuerySubmitChanges()EDMXADO.NET ProviderSQL Queryselect Name, Phonefrom customerswhere city = 'London'
OO vs. Relational WorldData TypesAssociationsGranularityInheritanceIdentity
EF ArchitectureSQLServerEDMLINQ to EntitiesEntity SQLConceptual ModelObject ServicesMappingEntity Client ProviderStorageModelADO.NET Provider
Entity Data Model (EDM)The EDM is the link between the model and the database.The EDM is that it decouples your application from the underlying store.Entity Data Model (EDM)StorageModel(SSDL)Mapping(MSL)Conceptual Model (CSDL)Storage
Object ServicesMaterialization The process of transforming the data obtained from the Entity Client data provider, which has a tabular structure, into objects. Change tracking Tracks any changes made to the objects.Query transformationTranslates queries it into a command tree that’s then passed on to the underlying Entity Client.Object identitiesObject Services FunctionsQueryingQuerying data as objects Shaping query results Composing queriesCRUD Lazy loadingInheritanceNavigating relationshipChange tracking Saving changesAttaching objectsDetaching objects Serializing objectsManagingObject identitiesConcurrencyTransactions
Entity SQL & LINQ to EntitiesLINQ to Entities - The  LINQ dialect that enables typed  queries against the model.Entity SQL - The second way of querying the object model.Entity SQL is string-based.Can be used to retrieve data at low level, directly using the Entity Client.
EDMLINQ to EntitiesEntity SQLConceptual ModelDevelopment ApproachesObject ServicesMappingEntity Client ProviderStorageModelADO.NET Provider
Database FirstDBIf 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. GeneratedData Model(.edmx)Database First
Model FirstGeneratedDBIf you don't yet have a database, you can begin by creating a model using the Entity Framework designer in Visual Studio. The designer can generate DDL (data definition language) statements to create the database. Data Model(.edmx)Model First
DBGeneratedData Model(Classes)Code FirstCode FirstGeneratedDBWhether 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.Data Model(Classes)Code First
Why DbContext & DbSet?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.Model DiscoveryModel CachingDbSet InitializationDatabase ProvisioningDbModelConstructorObjectContextConstructor* More info click here
EF 4.1 New API
Features That Are Not Supportedfeatures are not supported by the DbContextAPI. To use these features, use the ObjectContextAPI.Compiled queriesMEST (Multiple Entity Sets per Type)Self-tracking entities. To use the DbContext API in an N-tier application, consider using WCF Data Services or RIA Services.
Entity Framework Overview

Entity Framework Overview

  • 1.
    Entity FrameworkEyal VardiCEOE4D Solutions LTDMicrosoft MVP Visual C#blog: www.eVardi.com
  • 2.
    AgendaData Access HistoryOOvs. Relational WorldEF ArchitectureDevelopment ApproachesEF 4.0+ New APIEDMLINQ to EntitiesEntity SQLConceptual ModelObject ServicesMappingEntity Client ProviderStorageModelADO.NET Provider
  • 3.
  • 4.
    Services:- Change tracking-Concurrency control- Object identitySQL or Stored ProcsRowsSQLServerEntity FrameworkEntity Framework FlowApplicationfrom c in db.Customerswhere c.City == "London"select new { c.Name, c.Phone }ObjectsLINQ QuerySubmitChanges()EDMXADO.NET ProviderSQL Queryselect Name, Phonefrom customerswhere city = 'London'
  • 5.
    OO vs. RelationalWorldData TypesAssociationsGranularityInheritanceIdentity
  • 6.
    EF ArchitectureSQLServerEDMLINQ toEntitiesEntity SQLConceptual ModelObject ServicesMappingEntity Client ProviderStorageModelADO.NET Provider
  • 7.
    Entity Data Model(EDM)The EDM is the link between the model and the database.The EDM is that it decouples your application from the underlying store.Entity Data Model (EDM)StorageModel(SSDL)Mapping(MSL)Conceptual Model (CSDL)Storage
  • 8.
    Object ServicesMaterialization Theprocess of transforming the data obtained from the Entity Client data provider, which has a tabular structure, into objects. Change tracking Tracks any changes made to the objects.Query transformationTranslates queries it into a command tree that’s then passed on to the underlying Entity Client.Object identitiesObject Services FunctionsQueryingQuerying data as objects Shaping query results Composing queriesCRUD Lazy loadingInheritanceNavigating relationshipChange tracking Saving changesAttaching objectsDetaching objects Serializing objectsManagingObject identitiesConcurrencyTransactions
  • 9.
    Entity SQL &LINQ to EntitiesLINQ to Entities - The LINQ dialect that enables typed queries against the model.Entity SQL - The second way of querying the object model.Entity SQL is string-based.Can be used to retrieve data at low level, directly using the Entity Client.
  • 10.
    EDMLINQ to EntitiesEntitySQLConceptual ModelDevelopment ApproachesObject ServicesMappingEntity Client ProviderStorageModelADO.NET Provider
  • 11.
    Database FirstDBIf youalready 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. GeneratedData Model(.edmx)Database First
  • 12.
    Model FirstGeneratedDBIf youdon't yet have a database, you can begin by creating a model using the Entity Framework designer in Visual Studio. The designer can generate DDL (data definition language) statements to create the database. Data Model(.edmx)Model First
  • 13.
    DBGeneratedData Model(Classes)Code FirstCodeFirstGeneratedDBWhether 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.Data Model(Classes)Code First
  • 14.
    Why DbContext &DbSet?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.Model DiscoveryModel CachingDbSet InitializationDatabase ProvisioningDbModelConstructorObjectContextConstructor* More info click here
  • 15.
  • 16.
    Features That AreNot Supportedfeatures are not supported by the DbContextAPI. To use these features, use the ObjectContextAPI.Compiled queriesMEST (Multiple Entity Sets per Type)Self-tracking entities. To use the DbContext API in an N-tier application, consider using WCF Data Services or RIA Services.