Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />Agile Entity Framework 4<br />Julie Lerman<br />thedatafarm...
Julie Lerman<br />Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />website<br />theDataFarm.com<br />blog & ...
Agenda<br />Agile Entities<br />POCO Classes<br />Leveraging Proxies<br />Customizable T4 Code Generation<br />Persistence...
ObjectContext Manages Entities<br />Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />ObjectContext<br />Pers...
Agile Entities in EF4<br />EF3.5 Requires EntityObject<br />Provides automated entity management<br />Entities bound to EF...
POCO: Shifting the Responsibility<br />Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />ObjectSet<br />“Snap...
Basic POCO Support<br />Turn off code generation from EDMX<br />“Convention” will auto-map classes/entities<br />Julie Ler...
POCO and Other EF Features<br />Complex Types<br />Use a class (no structs) to represent the type<br />Explicit Loading<br...
Dynamic Proxies<br />Classes must be completely virtual<br />Every single property<br />Dynamic Proxy created at run time<...
Rules for Proxy Notification<br />All properties must be virtual<br />Use ICollection<T> for child collections<br />Object...
Code Gen POCOs from Model<br />Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />T4<br />More in Kathleen Dol...
Classes<br />Persistence Ignorance/Repository<br />System.Data.Entity<br />Mock<br />ObjectSet<br />Mock<br />Context A<br...
Agile Modeling in EF4<br />Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />*Available in separate download:...
Model First<br />Define model<br />Define entities, properties, property attributes<br />Entity Keys, Identity Keys <br />...
Code-Only Design<br />Part of the EF Feature CTP<br />No model at all<br />Metadata is inferred from classes<br />Conventi...
Resources<br />LearnEntityFramework.com/resources<br />thedatafarm.com/blog/tags/ef4<br />blogs.msdn.com/adonet, efdesign,...
Contact<br />Julie Lerman: Agile Entity Framework 4  [ESDC March 2010]<br />website<br />theDataFarm.com<br />blog & twitt...
Upcoming SlideShare
Loading in …5
×

Julie Lerman Agile Entity Framework (March 2010)

3,034 views

Published on

The Visual Studio 2010 EDM designer and the .NET 4 Entity Framework runtime introduce a new story to Entity Framework - agile code. EF now supports POCOs, Persistence Ignorance, Unit Testing, Model First development and even model-less development. THis is the latest version of this presentation given at www.go-esdc.com and East Bay.NET User group in early March 2010.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,034
On SlideShare
0
From Embeds
0
Number of Embeds
62
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Julie Lerman Agile Entity Framework (March 2010)

  1. 1. Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />Agile Entity Framework 4<br />Julie Lerman<br />thedatafarm.com/blog<br />jlerman@thedatafarm.com<br />Twitter @julielermanvt<br />
  2. 2. Julie Lerman<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<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 />2nd Edition<br />Spring 2010<br />
  3. 3. Agenda<br />Agile Entities<br />POCO Classes<br />Leveraging Proxies<br />Customizable T4 Code Generation<br />Persistence Ignorance<br />Agile Modeling<br />Model-First<br />(Model-less) Code-Only Development <br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  4. 4. ObjectContext Manages Entities<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />ObjectContext<br />Person Object<br />State info<br />State info<br />Order Object<br />State info<br />Detail Object<br />State info<br />Detail Object<br />State info<br />Order Object<br />State info<br />Detail Object<br />State info<br />Detail Object<br />
  5. 5. Agile Entities in EF4<br />EF3.5 Requires EntityObject<br />Provides automated entity management<br />Entities bound to EF API<br />EF4 Adds POCO Support<br />Smarter ObjectContext<br />Loose Coupling<br />Persistence Ignorance<br />Repositories & Unit Testing<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  6. 6. POCO: Shifting the Responsibility<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />ObjectSet<br />“Snapshot”<br />ObjectContext<br />POCO<br />Classes<br />DynamicProxy<br />(similar to EntityObject)<br />“Proxy Notification”<br />
  7. 7. Basic POCO Support<br />Turn off code generation from EDMX<br />“Convention” will auto-map classes/entities<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  8. 8. POCO and Other EF Features<br />Complex Types<br />Use a class (no structs) to represent the type<br />Explicit Loading<br />ObjectContext.LoadProperty(myObj,”PropertyName”)<br />ObjectContext.LoadProperty(myObj, o=>o.property)<br />Lazy Loading (new to EF4)<br />Virtual navigation properties get run-time proxy<br />Two-Way Navigation<br />Must be coded into classes<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  9. 9. Dynamic Proxies<br />Classes must be completely virtual<br />Every single property<br />Dynamic Proxy created at run time<br />Provide features similar to EntityObject<br />Change notification<br />Relationship management<br />Lazy Loading<br />Lots of rules <br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  10. 10. Rules for Proxy Notification<br />All properties must be virtual<br />Use ICollection<T> for child collections<br />ObjectContext.CreateObject<T> for new<br />Class cannot be sealed<br />Navigation properties cannot be sealed<br />Class cannot be abstract <br />Must have a constructor with no parameters<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  11. 11. Code Gen POCOs from Model<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />T4<br />More in Kathleen Dollard’s 2:30 talk, Wednesday:<br />T4: Code Generation Microsoft Style<br />Text Template Transformation Toolkit<br />
  12. 12. Classes<br />Persistence Ignorance/Repository<br />System.Data.Entity<br />Mock<br />ObjectSet<br />Mock<br />Context A<br />EDM &<br />ObjectContext<br />Mock<br />Context B<br />Class<br />Repositories<br />Class<br />Repositories<br />Class<br />Repositories<br />Class<br />Repositories<br />UI<br />Tests<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  13. 13. Agile Modeling in EF4<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />*Available in separate download: EF Feature CTP <br />
  14. 14. Model First<br />Define model<br />Define entities, properties, property attributes<br />Entity Keys, Identity Keys <br />Field Type, Length, defaults.<br />Relationships & their constraints (e.g. 1:*)<br />Inheritance (TPT default)<br />“Generate DB from Model” = Create DDL<br />Run DDL against existing DB<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  15. 15. Code-Only Design<br />Part of the EF 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 />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  16. 16. Resources<br />LearnEntityFramework.com/resources<br />thedatafarm.com/blog/tags/ef4<br />blogs.msdn.com/adonet, efdesign, dsimmons, alexj, more...<br />msdn.microsoft.com/data<br />Gateway to whitepapers, forums, documentation<br />Lots of bloggers on EF now! Google! <br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<br />
  17. 17. Contact<br />Julie Lerman: Agile Entity Framework 4 [ESDC March 2010]<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 />

×