EF4, the new version of Entity Framework in .NET 4.0, now supports agile development with the ability to use POCO (Plain Old CLR Objects) classes with EF. Now you can use your own classes without having to bind them to the Entity Framework APIs, yet still benefit from the querying, change tracking and updates that EF provides. One flavor of POCO is "in the box" and uses a model that you define. An extension to EF will also provide Code Only development where you will not even be required to build a model. This session will show you how to integrate your classes into the Entity Framework. See Part 2 to learn how to get the full benefit of this with unit testing and more.
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Â
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
1. Using POCOS in Entity Framework 4Part 1 Julie Lerman thedatafarm.com/blog jlerman@thedatafarm.com Julia Lerman October 17th 2009, New England Code Camp 12
2. Note to Viewers This is Part 1 of a two part presentation. Part 2 covers testing and other patterns and how EF4 supports them. It was presented by Jamie Phillips. You can find his presentation at http://devblog.petrellyn.com/?p=189 Julia Lerman October 17th 2009, New England Code Camp 12
3. Julie Lerman Julia Lerman October 17th 2009, New England Code Camp 12 website theDataFarm.com blog & twitter theDataFarm.com/blog@julielermanVT book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader
4. Agenda Standard EntityObject Classes Simple POCO Classes POCO and Proxies Generate POCO Classes with T4 Code-Only Development Julia Lerman October 17th 2009, New England Code Camp 12
5. EF1 & Default EF4 Gen’d Classes CustomTool=EntityModelCodeGenerator Julia Lerman October 17th 2009, New England Code Camp 12
6. POCO: Plain Old CLR Object Define your classes Not bound to other APIs e.g. no inheritance from EntityObject Classes are reusable Simplifies testing and more… Julia Lerman October 17th 2009, New England Code Camp 12
7. How Does EF4 Support POCO? EntityObjects interact with context For POCO, context does all of the work Classes don’t need to know about context Help provided by Special context methods Additional support via proxies Julia Lerman October 17th 2009, New England Code Camp 12
8. Basic POCO Support Turn off code generation from EDMX “Convention” will auto-map classes/entities Julia Lerman October 17th 2009, New England Code Camp 12
9. POCO and Other EF Features Complex Types: Supported Use a class (no structs) to represent the type Lazy Loading Declare property as virtual EF uses a proxy instance at runtime to load Explicit Loading ObjectContext.LoadProperty(myObj,”PropertyName”) ObjectCOntext.LoadProperty(myObj, o=>o.property) Julia Lerman October 17th 2009, New England Code Camp 12
10. Change Tracking Options Snapshot Default change tracking Collected with DetectChanges is called Notification based virtual properties use Proxies Proxies can provide notification to context Julia Lerman October 17th 2009, New England Code Camp 12
11. POCO Classes from Model Julia Lerman October 17th 2009, New England Code Camp 12 T4 Text Template Transformation Toolkit
12. Code-Only Design Part of the Feature CTP No model at all Metadata is inferred from classes Convention by Default EF will rely 100% on presumptions Configuration Follows Tweak configurations to modify behavior Julia Lerman October 17th 2009, New England Code Camp 12
13. Self-Tracking Entities Part of Feature CTP T4 Template to create specialized POCO classes EntityState is tracked by entity Specialized methods that know what to expect from the classes Julia Lerman October 17th 2009, New England Code Camp 12
15. Contact Julia Lerman October 17th 2009, New England Code Camp 12 website theDataFarm.com blog & twitter theDataFarm.com/blog@julielermanVT book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader