KEMBAR78
Entity Framework 4 and WCF | PPTX
Entity Framework 4 & WCF So Happy Together Julie Lermanwww.thedatafarm.comjlerman@thedatafarm.comtwitter @JulieLermanVTJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
Julie LermanwebsitetheDataFarm.comblog & twittertheDataFarm.com/blog@julielermanVTbook web siteLearnEntityFramework.comconsultant/mentorMicrosoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET LeaderJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]2nd EditionSpring 2010
AgendaNew Features in EF that help with n-TierPOCO SupportForeign KeysState methodsSerialization improvement	Custom WCF ServicesSelf-Tracking EntitiesJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
EFv1 and N-TierEntityObjects are ugly when serializedTransferring to & from DTOs is painfulNo change-tracking in the objectsDifficult & unsatisfying WCF patterns Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
ObjectContext Manages EntitiesJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]ObjectContextPerson ObjectState infoState infoOrder ObjectState infoDetail ObjectState infoDetail ObjectState infoOrder ObjectState infoDetail ObjectState infoDetail Object
Hello POCO, Goodbye EntityObjectJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
Code Gen POCOs from ModelT4More in Kathleen Dollard’s 2:30 talk, Wednesday:T4: Code Generation Microsoft StyleText Template Transformation ToolkitJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
New State Methods Support N-TierFix up newly attached entity’s EntityStateApplyCurrentValuesApplyOriginalValuesChangeStateChangeRelationshipStateUsed when there are no foreign keysJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
Context.ApplyCurrentValuesJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]Server EntityManaged by Context
EntityState=UnchangedClient side EntityEntityState=ModifiedApplyCurrentValues(Client Entity)
Foreign Key SupportDefault with new modelsSimplifies relationship managementHuge benefits from WCF client to serviceJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
Basic Pattern for WCF in EF4Use POCO entity classesNo dynamic proxies (not virtual)Include a State property in the classesReturn graphsAttach returned data to new contextFix up context state using POCO StateIf not using FKsFix up relationships with help from DB dataJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
Self-Tracking Entities (! very agile)For DataSet loversSpecial T4 Code Gen TemplateCreates POCO Classes with state infoCreates additional classes & interfaces“Magically: takes care of change trackingUsed in client (.NET 4.0) & serviceFor WCF/DataContract SerializationJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
SummaryWCF was painful in EF version 1Many improvements in EF4 to help n-TierWriting custom WCF gets much easierSelf-Tracking Entities are an out of the box solution to help DataSetdevsDon’t forget about WCF Data Services and WCF RIA Services as wellJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
Julie LermanwebsitetheDataFarm.comblog & twittertheDataFarm.com/blog@julielermanVTbook web siteLearnEntityFramework.comconsultant/mentorMicrosoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET LeaderJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]2nd EditionSpring 2010

Entity Framework 4 and WCF

  • 1.
    Entity Framework 4& WCF So Happy Together Julie Lermanwww.thedatafarm.comjlerman@thedatafarm.comtwitter @JulieLermanVTJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 2.
    Julie LermanwebsitetheDataFarm.comblog &twittertheDataFarm.com/blog@julielermanVTbook web siteLearnEntityFramework.comconsultant/mentorMicrosoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET LeaderJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]2nd EditionSpring 2010
  • 3.
    AgendaNew Features inEF that help with n-TierPOCO SupportForeign KeysState methodsSerialization improvement Custom WCF ServicesSelf-Tracking EntitiesJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 4.
    EFv1 and N-TierEntityObjectsare ugly when serializedTransferring to & from DTOs is painfulNo change-tracking in the objectsDifficult & unsatisfying WCF patterns Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 5.
    ObjectContext Manages EntitiesJulieLerman: Entity Framework 4 and WCF [ESDC March 2010]ObjectContextPerson ObjectState infoState infoOrder ObjectState infoDetail ObjectState infoDetail ObjectState infoOrder ObjectState infoDetail ObjectState infoDetail Object
  • 6.
    Hello POCO, GoodbyeEntityObjectJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 7.
    Code Gen POCOsfrom ModelT4More in Kathleen Dollard’s 2:30 talk, Wednesday:T4: Code Generation Microsoft StyleText Template Transformation ToolkitJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 8.
    New State MethodsSupport N-TierFix up newly attached entity’s EntityStateApplyCurrentValuesApplyOriginalValuesChangeStateChangeRelationshipStateUsed when there are no foreign keysJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 9.
    Context.ApplyCurrentValuesJulie Lerman: EntityFramework 4 and WCF [ESDC March 2010]Server EntityManaged by Context
  • 10.
  • 11.
    Foreign Key SupportDefaultwith new modelsSimplifies relationship managementHuge benefits from WCF client to serviceJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 12.
    Basic Pattern forWCF in EF4Use POCO entity classesNo dynamic proxies (not virtual)Include a State property in the classesReturn graphsAttach returned data to new contextFix up context state using POCO StateIf not using FKsFix up relationships with help from DB dataJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 13.
    Self-Tracking Entities (!very agile)For DataSet loversSpecial T4 Code Gen TemplateCreates POCO Classes with state infoCreates additional classes & interfaces“Magically: takes care of change trackingUsed in client (.NET 4.0) & serviceFor WCF/DataContract SerializationJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 14.
    SummaryWCF was painfulin EF version 1Many improvements in EF4 to help n-TierWriting custom WCF gets much easierSelf-Tracking Entities are an out of the box solution to help DataSetdevsDon’t forget about WCF Data Services and WCF RIA Services as wellJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
  • 15.
    Julie LermanwebsitetheDataFarm.comblog &twittertheDataFarm.com/blog@julielermanVTbook web siteLearnEntityFramework.comconsultant/mentorMicrosoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET LeaderJulie Lerman: Entity Framework 4 and WCF [ESDC March 2010]2nd EditionSpring 2010
  • 16.
    ResourcesJulie Lerman: EntityFramework 4 and WCF [ESDC March 2010]