This presentation walks through the new features of Entity Framework in Visual Studio 2010 & .NET 4 that simplify using entities in WCF. The live session demo'd the features and a WCF service with a client consumer.
1. Entity Framework 4 & WCF So Happy Together Julie Lerman www.thedatafarm.com jlerman@thedatafarm.com twitter @JulieLermanVT Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
2. Julie Lerman website theDataFarm.com blog & twitter theDataFarm.com/blog@julielermanVT book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010] 2nd Edition Spring 2010
3. Agenda New Features in EF that help with n-Tier POCO Support Foreign Keys State methods Serialization improvement Custom WCF Services Self-Tracking Entities Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
4. EFv1 and N-Tier EntityObjects are ugly when serialized Transferring to & from DTOs is painful No change-tracking in the objects Difficult & unsatisfying WCF patterns Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
5. ObjectContext Manages Entities Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010] ObjectContext Person Object State info State info Order Object State info Detail Object State info Detail Object State info Order Object State info Detail Object State info Detail Object
6. Hello POCO, Goodbye EntityObject Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
7. Code Gen POCOs from Model T4 More in Kathleen Dollard’s 2:30 talk, Wednesday: T4: Code Generation Microsoft Style Text Template Transformation Toolkit Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
8. New State Methods Support N-Tier Fix up newly attached entity’s EntityState ApplyCurrentValues ApplyOriginalValues ChangeState ChangeRelationshipState Used when there are no foreign keys Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
9.
10.
11. Foreign Key Support Default with new models Simplifies relationship management Huge benefits from WCF client to service Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
12. Basic Pattern for WCF in EF4 Use POCO entity classes No dynamic proxies (not virtual) Include a State property in the classes Return graphs Attach returned data to new context Fix up context state using POCO State If not using FKs Fix up relationships with help from DB data Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
13. Self-Tracking Entities (! very agile) For DataSet lovers Special T4 Code Gen Template Creates POCO Classes with state info Creates additional classes & interfaces “Magically: takes care of change tracking Used in client (.NET 4.0) & service For WCF/DataContract Serialization Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
14. Summary WCF was painful in EF version 1 Many improvements in EF4 to help n-Tier Writing custom WCF gets much easier Self-Tracking Entities are an out of the box solution to help DataSetdevs Don’t forget about WCF Data Services and WCF RIA Services as well Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010]
15. Julie Lerman website theDataFarm.com blog & twitter theDataFarm.com/blog@julielermanVT book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader Julie Lerman: Entity Framework 4 and WCF [ESDC March 2010] 2nd Edition Spring 2010