VVS13:WCF + Entity Frameworkin Visual Studio 2010<br />Julie Lerman<br />www.thedatafarm.com<br />jlerman@thedatafarm.com<...
Julie Lerman<br />website<br />theDataFarm.com<br />blog & twitter<br />theDataFarm.com/blog@julielermanVT<br />book web s...
Agenda<br />New Features in EF that help with n-tier<br />POCO Support<br />Foreign Keys<br />State methods<br />Serializa...
EFv1 and N-Tier<br />EntityObjects are ugly when serialized<br />Transferring to & from DTOs is painful<br />No change-tra...
Basic POCO Support in EF4<br />Turn off code generation from EDMX<br />“Convention” will auto-map classes/entities<br />
Additional POCO Features<br />Change Tracking<br />By Snapshot or Proxy<br />Lazy Loading<br />By Proxy<br />Code Only Des...
Simpler Code Gen Customization<br />T4<br />Text Template Transformation Toolkit<br />
New State Methods Support N-Tier<br />ApplyCurrentValues<br />ApplyOriginalValues<br />ChangeState<br />ChangeRelationship...
Change State w ApplyCurrentValues<br />Client  Requests<br />Object<br />Service queries db/cache &returns object<br />fNa...
Foreign Key Support<br />Arrived in Beta 2<br />Default with new models<br />Simplifies relationship management<br />
Basic Pattern for WCF in EF4<br />Use POCO entity classes<br />Include a State property in the classes<br />Return graphs<...
Self-Tracking Entities<br />Special API in Feature CTP<br />POCO Classes with state information<br />Special method to app...
Summary<br />WCF was painful in EF version 1<br />Many improvements in EF4 to help n-Tier<br />Writing custom WCF gets muc...
Julie Lerman<br />website<br />theDataFarm.com<br />blog & twitter<br />theDataFarm.com/blog@julielermanVT<br />book web s...
Resources<br />EF Team Blogs (blogs.msdn.com/)<br />adonet, efdesign, dsimmons, adjames, more..<br />Rowan Miller (romille...
Upcoming SlideShare
Loading in …5
×

Lerman Vvs13 Entity Framework 4 And Wcf

5,148 views

Published on

Julia Lerman
DevConnections Fall 2009 Session
Entity Framework 4 and WCF
www.learnentityframework.com

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total views
5,148
On SlideShare
0
From Embeds
0
Number of Embeds
51
Actions
Shares
0
Downloads
0
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Lerman Vvs13 Entity Framework 4 And Wcf

  1. 1. VVS13:WCF + Entity Frameworkin Visual Studio 2010<br />Julie Lerman<br />www.thedatafarm.com<br />jlerman@thedatafarm.com<br />twitter @JulieLermanVT<br />
  2. 2. Julie Lerman<br />website<br />theDataFarm.com<br />blog & twitter<br />theDataFarm.com/blog@julielermanVT<br />book web site<br />LearnEntityFramework.com<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />
  3. 3. Agenda<br />New Features in EF that help with n-tier<br />POCO Support<br />Foreign Keys<br />State methods<br />Serialization improvement <br />Custom WCF Services<br />Self-Tracking Entities<br />
  4. 4. EFv1 and N-Tier<br />EntityObjects are ugly when serialized<br />Transferring to & from DTOs is painful<br />No change-tracking in the objects<br />Difficult & unsatisfying WCF patterns <br />
  5. 5. Basic POCO Support in EF4<br />Turn off code generation from EDMX<br />“Convention” will auto-map classes/entities<br />
  6. 6. Additional POCO Features<br />Change Tracking<br />By Snapshot or Proxy<br />Lazy Loading<br />By Proxy<br />Code Only Design<br />No Physical Model<br />Convention and Configuration<br />
  7. 7. Simpler Code Gen Customization<br />T4<br />Text Template Transformation Toolkit<br />
  8. 8. New State Methods Support N-Tier<br />ApplyCurrentValues<br />ApplyOriginalValues<br />ChangeState<br />ChangeRelationshipState<br />Used when there are no foreign keys<br />
  9. 9. Change State w ApplyCurrentValues<br />Client Requests<br />Object<br />Service queries db/cache &returns object<br />fName: Julie<br />lName: Lerman<br /> Client User Edits Object & returns to service<br />fName: Julie<br />lName: Flynn<br />Service queries db/cache for original object<br />fName: Julie<br />fName: Julie<br />lName: Lerman<br />Service updates original object with values from client<br />lName: Flynn<br />SaveChanges<br />ApplyCurrentValues<br />
  10. 10. Foreign Key Support<br />Arrived in Beta 2<br />Default with new models<br />Simplifies relationship management<br />
  11. 11. Basic Pattern for WCF in EF4<br />Use POCO entity classes<br />Include a State property in the classes<br />Return graphs<br />Attach returned data to new context<br />Fix up context state using POCO state<br />If not using FKs<br />Fix up relationships with help from db data<br />
  12. 12. Self-Tracking Entities<br />Special API in Feature CTP<br />POCO Classes with state information<br />Special method to apply changes to an entire graph<br />Magically takes care of change tracking<br />Written for WCF and DataContract Serialization<br />Does not apply to ASP.NET, etc.<br />
  13. 13. Summary<br />WCF was painful in EF version 1<br />Many improvements in EF4 to help n-Tier<br />Writing custom WCF gets much easier<br />Self-Tracking Entities are a good out of the box solution<br />Don’t forget about ADO.NET Data Services and RIA Services as well<br />
  14. 14. Julie Lerman<br />website<br />theDataFarm.com<br />blog & twitter<br />theDataFarm.com/blog@julielermanVT<br />book web site<br />LearnEntityFramework.com<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />
  15. 15. Resources<br />EF Team Blogs (blogs.msdn.com/)<br />adonet, efdesign, dsimmons, adjames, more..<br />Rowan Miller (romiller.com) (EF Team)<br />WCF EF POCO demo with unit tests<br />Danny Simmons’ Aug 2009 MSDN Mag<br />MS PAG: Data Access Guidance <br />dataguidance.codeplex.com<br />

×