SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Entity Framework 4POCO & Persistence Ignorance Julie Lerman thedatafarm.com jlerman@thedatafarm.com Twitter @julielerman Julie Lerman, August 10, 2010 Cleveland .NET SIg
Julie Lerman website theDataFarm.com blog & twitter theDataFarm.com/blog@julielerman book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader 2nd edition in August Julie Lerman, August 10, 2010 Cleveland .NET SIg
    Sponsored by INETA	  The Face of .NET World-wide association of .NET User Groups 860+ groups world-wide Over 810,000 developers Started and run by .NET User Group leaders Sponsors and supports both .NET and other professional user groups all around the world Sponsors Microsoft New sponsors welcome! North America (NorAm) INETA Speaker Bureau consists of  86 world-renowned speakers www.ineta.org Julie Lerman, May 11 2010, for HUNTUG
Julie Lerman, August 10, 2010 Cleveland .NET SIg Persistence Dependent var context = new PublishingEntities(); var book= (from b in context select books where bookid=3).First(); b.Status = “Sent to Printer”; Context.SaveChanges(); Persistence Ignorance varbookMgr = new BookManager() var book=bookMgr.GetBook(3); book.Status=“Sent to Printer”; bookMgr.Update(book);
EF1 & Default EF4 Classes Julie Lerman, August 10, 2010 Cleveland .NET SIg
POCO: Shifting the Responsibility Julie Lerman, August 10, 2010 Cleveland .NET SIg ? ObjectContext Context.DetectChanges POCO Classes “Snapshot” OR EntityObject Proxy “Proxy Notification”
ObjectContext Manages Entities POCO “Snapshot”4.0 POCO + Dynamic Runtime Proxy  (4.0) EntityObject (3.5 & 4.0) 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 Julie Lerman, August 10, 2010 Cleveland .NET SIg
Basic POCO Support Turn off code generation from EDMX “Convention” will auto-map classes/entities Julie Lerman, August 10, 2010 Cleveland .NET SIg
POCO and Other EF Features Complex Types: Supported Use a class (no structs) to represent the type Explicit Loading ObjectContext.LoadProperty(myObj,”PropertyName”) ObjectCOntext.LoadProperty(myObj, o=>o.property) Lazy Loading (new to EF4!) Declare property as virtual EF uses a proxy instance at runtime to load Julie Lerman, August 10, 2010 Cleveland .NET SIg
Rules for Proxy Notification All properties  of the model entity must be virtual Use ICollection<T> for child collections ObjectContext.CreateObject<T> for new Class cannot be sealed Navigation props cannot be sealed Class cannot be abstract           Constructor with no parameters Julie Lerman, August 10, 2010 Cleveland .NET SIg
POCO Classes from Model Julie Lerman, August 10, 2010 Cleveland .NET SIg T4 Text Template Transformation Toolkit
P.I.? Huh? EF1 Julie Lerman, August 10, 2010 Cleveland .NET SIg
EF4 Julie Lerman, August 10, 2010 Cleveland .NET SIg
EF4 POCO Support All entity properties must be represented Hand Code Code Gen with T4 Snapshot ObjectContext does all of the work Lazy Loading Virtual navigation properties Dynamic Runtime Proxies Every single property is virtual Proxy emulates EntityObject behavior Julie Lerman, August 10, 2010 Cleveland .NET SIg
IObjectSet for Separation Set with Collection-like behavior Add, Attach, Delete, etc. ObjectSet Concrete class Implements IObjectSet Inherits ObjectQuery Julie Lerman, August 10, 2010 Cleveland .NET SIg
Classes PI/Repositories System.Data.Entity Fake ObjectSet Fake Context & Data A EDM & ObjectContext Fake Context & Data B Unit of Work Class Repositories Class Repositories Class Repositories Class Repositories UI Tests Julie Lerman, August 10, 2010 Cleveland .NET SIg
Entity Framework 4 Supports POCO Separation of concerns Unit Testing Coming soon: Code First Currently part of CTP4, not part of .NET 4 Julie Lerman, August 10, 2010 Cleveland .NET SIg
Resources msdn.com/data Learnentityframework.com Testability and Entity Framework 4.0,Scott Allen, http://msdn.microsoft.com/en-us/ff714955.aspx Agile Entity Framework 4 Repository: blog series http://thedatafarm.com/blog/data-access/agile-entity-framework-4-repository-part-1-model-and-poco-classes/ Julie Lerman, August 10, 2010 Cleveland .NET SIg
Julie Lerman website theDataFarm.com blog & twitter theDataFarm.com/blog@julielerman book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader 2nd edition in August Julie Lerman, August 10, 2010 Cleveland .NET SIg

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (10)

Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesThe 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
 
Domain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVCDomain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVC
 
A visual introduction to Event Sourcing and CQRS
A visual introduction to Event Sourcing and CQRSA visual introduction to Event Sourcing and CQRS
A visual introduction to Event Sourcing and CQRS
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 

Ähnlich wie Persistence Ignorance in Entity Framework 4, Julie Lerman

Jaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social WebJaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social Web
Patrick Chanezon
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
marvin337
 
Intriduction to Ontotext's KIM platform
Intriduction to Ontotext's KIM platformIntriduction to Ontotext's KIM platform
Intriduction to Ontotext's KIM platform
toncho11
 
What's New with Windows Phone - FoxCon Talk
What's New with Windows Phone - FoxCon TalkWhat's New with Windows Phone - FoxCon Talk
What's New with Windows Phone - FoxCon Talk
Sam Basu
 

Ähnlich wie Persistence Ignorance in Entity Framework 4, Julie Lerman (20)

Julie Lerman Agile Entity Framework (March 2010)
Julie Lerman Agile Entity Framework (March 2010)Julie Lerman Agile Entity Framework (March 2010)
Julie Lerman Agile Entity Framework (March 2010)
 
Perspectives on Entity Framework, Julie Lerman
Perspectives on Entity Framework, Julie LermanPerspectives on Entity Framework, Julie Lerman
Perspectives on Entity Framework, Julie Lerman
 
Entity Framework 4 and WCF
Entity Framework 4 and WCFEntity Framework 4 and WCF
Entity Framework 4 and WCF
 
Entity Framework NYC Firestarter
Entity Framework NYC FirestarterEntity Framework NYC Firestarter
Entity Framework NYC Firestarter
 
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie LermanUsing Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
 
Spring ActionScript
Spring ActionScriptSpring ActionScript
Spring ActionScript
 
Open Social Phpcamp
Open Social PhpcampOpen Social Phpcamp
Open Social Phpcamp
 
Entity Framework 4 In Microsoft Visual Studio 2010
Entity Framework 4 In Microsoft Visual Studio 2010Entity Framework 4 In Microsoft Visual Studio 2010
Entity Framework 4 In Microsoft Visual Studio 2010
 
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelEntity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
 
Jaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social WebJaoo - Open Social A Standard For The Social Web
Jaoo - Open Social A Standard For The Social Web
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
 
Lerman Vvs13 Entity Framework 4 And Wcf
Lerman Vvs13 Entity Framework 4 And WcfLerman Vvs13 Entity Framework 4 And Wcf
Lerman Vvs13 Entity Framework 4 And Wcf
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure Functions
 
Goodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social UpdateGoodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social Update
 
What's New in Entity Framework 4, by Julie Lerman
What's New in Entity Framework 4, by Julie LermanWhat's New in Entity Framework 4, by Julie Lerman
What's New in Entity Framework 4, by Julie Lerman
 
Intriduction to Ontotext's KIM platform
Intriduction to Ontotext's KIM platformIntriduction to Ontotext's KIM platform
Intriduction to Ontotext's KIM platform
 
Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
Building n-Tier ASP.NET WebForms with Entity Framework 4, LermanBuilding n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
 
What's New with Windows Phone - FoxCon Talk
What's New with Windows Phone - FoxCon TalkWhat's New with Windows Phone - FoxCon Talk
What's New with Windows Phone - FoxCon Talk
 
solution Challenge design and flutter day.pptx
solution Challenge design and flutter day.pptxsolution Challenge design and flutter day.pptx
solution Challenge design and flutter day.pptx
 
Open social
Open socialOpen social
Open social
 

Mehr von Julie Lerman

Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)
Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)
Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)
Julie Lerman
 
Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)
Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)
Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)
Julie Lerman
 
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Julie Lerman
 

Mehr von Julie Lerman (17)

EF Core in Containerized ASP.NET Core APIs
EF Core in Containerized ASP.NET Core APIsEF Core in Containerized ASP.NET Core APIs
EF Core in Containerized ASP.NET Core APIs
 
Domain-Driven Design with Tender Loving Care (DDD with TLC)
Domain-Driven Design with Tender Loving Care (DDD with TLC)Domain-Driven Design with Tender Loving Care (DDD with TLC)
Domain-Driven Design with Tender Loving Care (DDD with TLC)
 
What's New in Visual Studio 2017
What's New in Visual Studio 2017What's New in Visual Studio 2017
What's New in Visual Studio 2017
 
A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important Features
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?
 
Microsoft for developers open source and cross platform
Microsoft for developers  open source and cross platformMicrosoft for developers  open source and cross platform
Microsoft for developers open source and cross platform
 
RavenDB Overview
RavenDB OverviewRavenDB Overview
RavenDB Overview
 
Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)
Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)
Julie Lerman: Entity Framework FTQs (Frequently Tweeted Questions)
 
Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)
Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)
Julie Lerman Entity Framework in the Enterprise (Boston Code Camp March 2013)
 
Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Entity Framework Today (May 2012)
Entity Framework Today (May 2012)
 
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
 
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie LermanGetting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
 
Persistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanPersistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie Lerman
 
AgileEntity Framework 4
AgileEntity Framework 4AgileEntity Framework 4
AgileEntity Framework 4
 
Lerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In AspnetLerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In Aspnet
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 
Data in the Azure Cloud, by Julie Lerman
Data in the Azure Cloud, by Julie LermanData in the Azure Cloud, by Julie Lerman
Data in the Azure Cloud, by Julie Lerman
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Persistence Ignorance in Entity Framework 4, Julie Lerman

  • 1. Entity Framework 4POCO & Persistence Ignorance Julie Lerman thedatafarm.com jlerman@thedatafarm.com Twitter @julielerman Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 2. Julie Lerman website theDataFarm.com blog & twitter theDataFarm.com/blog@julielerman book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader 2nd edition in August Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 3. Sponsored by INETA The Face of .NET World-wide association of .NET User Groups 860+ groups world-wide Over 810,000 developers Started and run by .NET User Group leaders Sponsors and supports both .NET and other professional user groups all around the world Sponsors Microsoft New sponsors welcome! North America (NorAm) INETA Speaker Bureau consists of 86 world-renowned speakers www.ineta.org Julie Lerman, May 11 2010, for HUNTUG
  • 4. Julie Lerman, August 10, 2010 Cleveland .NET SIg Persistence Dependent var context = new PublishingEntities(); var book= (from b in context select books where bookid=3).First(); b.Status = “Sent to Printer”; Context.SaveChanges(); Persistence Ignorance varbookMgr = new BookManager() var book=bookMgr.GetBook(3); book.Status=“Sent to Printer”; bookMgr.Update(book);
  • 5. EF1 & Default EF4 Classes Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 6. POCO: Shifting the Responsibility Julie Lerman, August 10, 2010 Cleveland .NET SIg ? ObjectContext Context.DetectChanges POCO Classes “Snapshot” OR EntityObject Proxy “Proxy Notification”
  • 7. ObjectContext Manages Entities POCO “Snapshot”4.0 POCO + Dynamic Runtime Proxy (4.0) EntityObject (3.5 & 4.0) 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 Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 8. Basic POCO Support Turn off code generation from EDMX “Convention” will auto-map classes/entities Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 9. POCO and Other EF Features Complex Types: Supported Use a class (no structs) to represent the type Explicit Loading ObjectContext.LoadProperty(myObj,”PropertyName”) ObjectCOntext.LoadProperty(myObj, o=>o.property) Lazy Loading (new to EF4!) Declare property as virtual EF uses a proxy instance at runtime to load Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 10. Rules for Proxy Notification All properties of the model entity must be virtual Use ICollection<T> for child collections ObjectContext.CreateObject<T> for new Class cannot be sealed Navigation props cannot be sealed Class cannot be abstract Constructor with no parameters Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 11. POCO Classes from Model Julie Lerman, August 10, 2010 Cleveland .NET SIg T4 Text Template Transformation Toolkit
  • 12. P.I.? Huh? EF1 Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 13. EF4 Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 14. EF4 POCO Support All entity properties must be represented Hand Code Code Gen with T4 Snapshot ObjectContext does all of the work Lazy Loading Virtual navigation properties Dynamic Runtime Proxies Every single property is virtual Proxy emulates EntityObject behavior Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 15. IObjectSet for Separation Set with Collection-like behavior Add, Attach, Delete, etc. ObjectSet Concrete class Implements IObjectSet Inherits ObjectQuery Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 16. Classes PI/Repositories System.Data.Entity Fake ObjectSet Fake Context & Data A EDM & ObjectContext Fake Context & Data B Unit of Work Class Repositories Class Repositories Class Repositories Class Repositories UI Tests Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 17. Entity Framework 4 Supports POCO Separation of concerns Unit Testing Coming soon: Code First Currently part of CTP4, not part of .NET 4 Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 18. Resources msdn.com/data Learnentityframework.com Testability and Entity Framework 4.0,Scott Allen, http://msdn.microsoft.com/en-us/ff714955.aspx Agile Entity Framework 4 Repository: blog series http://thedatafarm.com/blog/data-access/agile-entity-framework-4-repository-part-1-model-and-poco-classes/ Julie Lerman, August 10, 2010 Cleveland .NET SIg
  • 19. Julie Lerman website theDataFarm.com blog & twitter theDataFarm.com/blog@julielerman book web site LearnEntityFramework.com consultant/mentor Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader 2nd edition in August Julie Lerman, August 10, 2010 Cleveland .NET SIg