Using POCOS in Entity Framework 4Part 1<br />Julie Lerman<br />thedatafarm.com/blog<br />jlerman@thedatafarm.com<br />Juli...
Note to Viewers<br />This is Part 1 of a two part presentation. Part 2 covers testing and other patterns and how EF4 suppo...
Julie Lerman<br />Julia Lerman  October 17th 2009, New England Code Camp 12<br />website<br />theDataFarm.com<br />blog & ...
Agenda<br />Standard EntityObject Classes<br />Simple POCO Classes<br />POCO and Proxies<br />Generate POCO Classes with T...
EF1 & Default EF4 Gen’d Classes<br />CustomTool=EntityModelCodeGenerator<br />Julia Lerman  October 17th 2009, New England...
POCO: Plain Old CLR Object<br />Define your classes<br />Not bound to other APIs<br />e.g. no inheritance from EntityObjec...
How Does EF4 Support POCO?<br />EntityObjects interact with context<br />For POCO, context does all of the work<br />Class...
Basic POCO Support<br />Turn off code generation from EDMX<br />“Convention” will auto-map classes/entities<br />Julia Ler...
POCO and Other EF Features<br />Complex Types: Supported<br />Use a class (no structs) to represent the type<br />Lazy Loa...
Change Tracking Options<br />Snapshot<br />Default change tracking<br />Collected with DetectChanges is called<br />Notifi...
POCO Classes from Model<br />Julia Lerman  October 17th 2009, New England Code Camp 12<br />T4<br />Text Template Transfor...
Code-Only Design<br />Part of the Feature CTP<br />No model at all<br />Metadata is inferred from classes<br />Convention ...
Self-Tracking Entities<br />Part of Feature CTP<br />T4 Template to create specialized POCO classes<br />EntityState is tr...
Resources<br />LearnEntityFramework.com/resources<br />blogs.msdn.com/adonet, efdesign, dsimmons, alexj, more...<br />msdn...
Contact<br />Julia Lerman  October 17th 2009, New England Code Camp 12<br />website<br />theDataFarm.com<br />blog & twitt...
Upcoming SlideShare
Loading in …5
×

Using Entity Framework's New POCO Features: Part 1, by Julie Lerman

5,436 views
5,363 views

Published on

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.

Published in: Technology, Travel, Sports
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,436
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Using Entity Framework's New POCO Features: Part 1, by Julie Lerman

  1. 1. Using POCOS in Entity Framework 4Part 1<br />Julie Lerman<br />thedatafarm.com/blog<br />jlerman@thedatafarm.com<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  2. 2. Note to Viewers<br />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<br />http://devblog.petrellyn.com/?p=189<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  3. 3. Julie Lerman<br />Julia Lerman October 17th 2009, New England Code Camp 12<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 />
  4. 4. Agenda<br />Standard EntityObject Classes<br />Simple POCO Classes<br />POCO and Proxies<br />Generate POCO Classes with T4<br />Code-Only Development <br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  5. 5. EF1 & Default EF4 Gen’d Classes<br />CustomTool=EntityModelCodeGenerator<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  6. 6. POCO: Plain Old CLR Object<br />Define your classes<br />Not bound to other APIs<br />e.g. no inheritance from EntityObject<br />Classes are reusable<br />Simplifies testing<br />and more…<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  7. 7. How Does EF4 Support POCO?<br />EntityObjects interact with context<br />For POCO, context does all of the work<br />Classes don’t need to know about context<br />Help provided by<br />Special context methods<br />Additional support via proxies<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  8. 8. Basic POCO Support<br />Turn off code generation from EDMX<br />“Convention” will auto-map classes/entities<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  9. 9. POCO and Other EF Features<br />Complex Types: Supported<br />Use a class (no structs) to represent the type<br />Lazy Loading<br />Declare property as virtual<br />EF uses a proxy instance at runtime to load<br />Explicit Loading<br />ObjectContext.LoadProperty(myObj,”PropertyName”)<br />ObjectCOntext.LoadProperty(myObj, o=&gt;o.property)<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  10. 10. Change Tracking Options<br />Snapshot<br />Default change tracking<br />Collected with DetectChanges is called<br />Notification based<br />virtual properties use Proxies<br />Proxies can provide notification to context<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  11. 11. POCO Classes from Model<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />T4<br />Text Template Transformation Toolkit<br />
  12. 12. Code-Only Design<br />Part of the Feature CTP<br />No model at all<br />Metadata is inferred from classes<br />Convention by Default<br />EF will rely 100% on presumptions<br />Configuration Follows<br />Tweak configurations to modify behavior<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  13. 13. Self-Tracking Entities<br />Part of Feature CTP<br />T4 Template to create specialized POCO classes<br />EntityState is tracked by entity<br />Specialized methods that know what to expect from the classes<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  14. 14. Resources<br />LearnEntityFramework.com/resources<br />blogs.msdn.com/adonet, efdesign, dsimmons, alexj, more...<br />msdn.microsoft.com/data<br />Gateway to whitepapers, forums, documentation<br />Julia Lerman October 17th 2009, New England Code Camp 12<br />
  15. 15. Contact<br />Julia Lerman October 17th 2009, New England Code Camp 12<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 />

×