Building n-Tier ASP.NET Web Forms with Entity FrameworkJulie Lermanthedatafarm.comjlerman@thedatafarm.comTwitter @julielerman
Julie Lermanconsultant/mentorMicrosoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET LeaderwebsitetheDataFarm.comblog & twittertheDataFarm.com/blog@julielermanbook web siteLearnEntityFramework.com2nd Edition (EF4) is now available
AgendaEF Challenges in Web AppsReview WebForm Options with EFEF4 Tools to the RescuePOCOs and RepositoriesLeveraging Foreign KeysPutting it all together
The ASP.net Spectrum with EFDynamic Data forEntitiesObjectDataSourceEntityDataSourceMVCADO.NETDataServicesDevWCFn-TierArchitect
Change Tracking Across TiersObjectContextObjectStateEntrySO1 EntityKey Original ValuesCurrent Values Other ∆ Info ObjectStateEntrySO2 EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info detachentitiesObjectStateEntryLIA EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info Original  Property ValuesEntityState ValuesObjectStateEntryLIB EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info
SaveChanges Fails Across Post BacksPage RequestPost Back #1Post Back #2New Page ClassNew Page ClassNew Page ClassCreate New ObjectContextCreate  NewObjectContextCreate  NewObjectContextGet EntitiesProcess RequestGet EntitiesBuild HTML using Data & ASP.NET MarkupBuild HTML using Data & ASP.NET MarkupBuild HTML using Data & ASP.NET MarkupDestroy Page and DependentsDestroy Page and DependentsDestroy Page and Dependents
EF4 Changes to the RescueForeign KeysBig help for selected list values on postbackState MethodsApplyCurrentValues, ApplyOriginalValuesChangeStateChangeRelationshipState (when no FKs)POCO Classes & T4 Generation
What about?GraphsLazy LoadingReturning IQueryablesChangeTracking
POCO BasicsWith or without code gen from EDMX“Convention” will auto-map classes/entities
EF Related Architectural ChoicesClassesvs.Repositoriesvs.
Basic Pattern for ASP.NET n-TierCode BehindBusiness LogicRepositoryTransient ObjectContext, QueriesCacheEntityKeys, Scalars (inc FKs)Foreign Keys make this approach a possibilityEntity Framework
Julie Lermanconsultant/mentorMicrosoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET LeaderwebsitetheDataFarm.comblog & twittertheDataFarm.com/blog@julielermanbook web siteLearnEntityFramework.com2nd Edition (EF4) is now available
Your Feedback is ImportantPlease fill out a session evaluation form drop it off at the conference registration desk.Thank you!

Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman

  • 1.
    Building n-Tier ASP.NETWeb Forms with Entity FrameworkJulie Lermanthedatafarm.comjlerman@thedatafarm.comTwitter @julielerman
  • 2.
    Julie Lermanconsultant/mentorMicrosoft MVP,INETA Speaker,ASPInsider, MCP, VTdotNET LeaderwebsitetheDataFarm.comblog & twittertheDataFarm.com/blog@julielermanbook web siteLearnEntityFramework.com2nd Edition (EF4) is now available
  • 3.
    AgendaEF Challenges inWeb AppsReview WebForm Options with EFEF4 Tools to the RescuePOCOs and RepositoriesLeveraging Foreign KeysPutting it all together
  • 4.
    The ASP.net Spectrumwith EFDynamic Data forEntitiesObjectDataSourceEntityDataSourceMVCADO.NETDataServicesDevWCFn-TierArchitect
  • 5.
    Change Tracking AcrossTiersObjectContextObjectStateEntrySO1 EntityKey Original ValuesCurrent Values Other ∆ Info ObjectStateEntrySO2 EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info detachentitiesObjectStateEntryLIA EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info Original Property ValuesEntityState ValuesObjectStateEntryLIB EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info
  • 6.
    SaveChanges Fails AcrossPost BacksPage RequestPost Back #1Post Back #2New Page ClassNew Page ClassNew Page ClassCreate New ObjectContextCreate NewObjectContextCreate NewObjectContextGet EntitiesProcess RequestGet EntitiesBuild HTML using Data & ASP.NET MarkupBuild HTML using Data & ASP.NET MarkupBuild HTML using Data & ASP.NET MarkupDestroy Page and DependentsDestroy Page and DependentsDestroy Page and Dependents
  • 7.
    EF4 Changes tothe RescueForeign KeysBig help for selected list values on postbackState MethodsApplyCurrentValues, ApplyOriginalValuesChangeStateChangeRelationshipState (when no FKs)POCO Classes & T4 Generation
  • 8.
  • 9.
    POCO BasicsWith orwithout code gen from EDMX“Convention” will auto-map classes/entities
  • 10.
    EF Related ArchitecturalChoicesClassesvs.Repositoriesvs.
  • 11.
    Basic Pattern forASP.NET n-TierCode BehindBusiness LogicRepositoryTransient ObjectContext, QueriesCacheEntityKeys, Scalars (inc FKs)Foreign Keys make this approach a possibilityEntity Framework
  • 12.
    Julie Lermanconsultant/mentorMicrosoft MVP,INETA Speaker,ASPInsider, MCP, VTdotNET LeaderwebsitetheDataFarm.comblog & twittertheDataFarm.com/blog@julielermanbook web siteLearnEntityFramework.com2nd Edition (EF4) is now available
  • 13.
    Your Feedback isImportantPlease fill out a session evaluation form drop it off at the conference registration desk.Thank you!

Editor's Notes

  • #2 Abtract: Creating n-tier applications with Entity Framework got a whole lot easier in .NET 4.0. But if you are using ASP.NET Web Forms, there are still some tricks that you’ll need to know, especially if you are not a fan of using the binding sources, such as EntityDataSource and ObjectDataSource. In this session, you’ll see how to create a bridge between your Web Forms and a repository which serves up Entity Framework entities. You’ll lean some of the tools you’ll need to handle related datasuch as master-detail and foreign key