Presentation is loading. Please wait.

Presentation is loading. Please wait.

Daniel Simmons Dev Manager Microsoft Session Code: DTL401.

Similar presentations


Presentation on theme: "Daniel Simmons Dev Manager Microsoft Session Code: DTL401."— Presentation transcript:

1

2 Daniel Simmons Dev Manager Microsoft Session Code: DTL401

3 Agenda Goals Priority 1: Increase success with the EF now Priority 2: Prepare for what is coming in EF4 Approach: Create an EF N-Tier Web Application Sketch architecture Build EF data access layer and business objects Customize code generation to add OnValidate Create fake repository and web application Add WCF service and real repository

4 Target Architecture DB & Service Tier Data Access Layer Business Objects WCF Service Web Server WCF Client Business Objects Web UI Browser

5 Architectural Considerations Know what tiers are needed and why Tier may have multiple layers Sample mid-tier has DAL, business objects and service Sample web-tier has repository, business objects and UI Sample separates web-tier from mid-tier because… Reduces internal network surface exposed to the DMZ Creates option for web-tier scale out Consider service operations and payload shapes Factors include change rates and trust boundaries Sample uses custom services and shared entities

6 Mid-Tier Persistence Entity Partial Classes Entity Framework Context Entities DAL Business Objects Generated Hand-Written

7 Demo #1: DAL and Business Objects Look at an EF Model based on Northwind Examine modifications for concurrency checks Debug optimistic concurrency in action

8 DAL and Business Objects

9 Demo 1 Takeaways EF enables separate DAL and business object layers, but there is much less code to write Hand-written DAL is replaced by combination of: EF storage/entity mapping generated context Business objects also generated, but extended with custom business logic Pay attention to concurrency Especially in disconnected scenarios

10 T4 Output Text Control Code Template Metadata Generated Code T4

11 Demo #2: T4 and OnValidate Add T4 template to customize generated code Modify template for OnValidate mechanism Add partial class with validation code Test validation

12 T4 and OnValidate

13 Demo 2 Takeaways T4 makes customizing code generation easy EF4 will use T4 in a big way Register SavingChanges event handler during context construction EF4 makes SaveChanges virtual ObjectStateManager tracks all changes Use LINQ to Objects to interrogate it Avoid modifying other entities in OnValidate

14 Web Tier & Repository Pattern Repository Fake Impl Real Impl Web UI Business Objects

15 Demo #3: Fake Repository & Web UI Add ICustomerRepository interface Create fake implementation Pull in Web UI written using the repository

16 Fake Repository & Web UI

17 Demo 3 Takeaways Mental model of a repository is an in-memory collection Centralizes all data access in one place Easy to understand and tune if needed De-couples rest of application from data access Easily create fake or mock implementations Enables multiple real implementations Did I mention that it de-couples the rest of your application from data access?

18 Cross-tier Communication Persistence WCF Service Web-tier WCF Client Repository Mid-tier Serialized Entities

19 Demo #4: Connecting the Dots Turn ICustomerRepository into service contract Extend context class with AttachAsModified Add implementation of service contract Examine EF disconnected updates Test the implementation Examine web tier auto-proxy repository Run the final application

20 Connecting the Dots

21 Demo 4 Takeaways Concurrency for disconnected operations Maintain concurrency value from first read Change-tracking for disconnected operations Individual property tracking often unnecessary Disconnected graph manipulation Mixed operations quite difficult in 3.5 sp1 State transitions also constrained in 3.5 sp1 Context operations treat graph uniformly Improvements here in EF4 (APIs, Self-Tracking)

22 What Next? Same patterns apply to.net 3.5 sp1 rich clients EF4 POCO support adds many options Completely separate business objects from DAL Serialize business objects to Silverlight,.Net 2.0, … Additional flexibility in business logic and testability Model-first enables generating DB Code-only removes need for separate metadata and mapping info

23

24 More Resources Code EF: http://msdn.microsoft.com/en-us/data/aa937723.aspx http://msdn.microsoft.com/en-us/data/aa937723.aspx EF FAQ: http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx ASP.Net MVC: http://www.asp.net/mvc http://www.asp.net/mvc Docs Sample: http://code.msdn.microsoft.com/dtl401sample http://code.msdn.microsoft.com/dtl401sample T4 Templates: http://code.msdn.microsoft.com/t4ef35sp1 http://code.msdn.microsoft.com/t4ef35sp1 Blogs Mine: http://blogs.msdn.com/dsimmons http://blogs.msdn.com/dsimmons EF Design: http://blogs.msdn.com/efdesign http://blogs.msdn.com/efdesign ADO.Net Team: http://blogs.msdn.com/adonet http://blogs.msdn.com/adonet

25 Related Content Breakout Sessions DAT308 Design Patterns for Application Architecture with the ADO.NET EF DTL05-INT Surprise! It's the Entity Framework Gotchas DTL312 The ADO.NET Entity Framework: Tips and Tricks Birds of a Feather BOF21 Solving the Unforeseen Challenges of the ADO.NET Entity Framework: How Can.NET Developers Get Better Prepared? BOF65 Implementing the Entity Framework in an n-Tier World Hands-on Labs DTL20-HOL Application Development with the ADO.NET Entity Framework in the Microsoft.NET Framework 4.0

26 Track Resources Visit the DPR TLC for a chance to win a copy of Visual Studio Team Suite. Daily drawing occurs every day in the TLC at 4:15pm. Stop by for a raffle ticket http://www.microsoft.com/visualstudio http://www.microsoft.com/visualstudio/en- us/products/teamsystem/default.mspx Please visit us in the TLC blue area

27 www.microsoft.com/teched Sessions On-Demand & Community http://microsoft.com/technet Resources for IT Professionals http://microsoft.com/msdn Resources for Developers www.microsoft.com/learning Microsoft Certification and Training Resources www.microsoft.com/learning Microsoft Certification & Training Resources Resources

28 Complete an evaluation on CommNet and enter to win!

29 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

30 PowerPoint Guidelines Subtitle color SampleSample SampleSample SampleSampleSampleSampleSampleSample Sample Sample Sample SampleSample SampleSample SampleSample SampleSample SampleSample SampleSample SampleSample SampleSample Sample Set as default shape SampleSample SampleSampleSampleSample Sample SampleSample SampleSampleSampleSample SampleSample SampleSampleSampleSample SampleSample SampleSample SampleSample SampleSample SampleSample Database SampleSample Itinerary Processing Resolvers Adapter Providers SampleSample

31

32 Name Title Company Session Code:

33 Hidden Speaker Notes Some speakers at Microsoft like to use this slide for hidden “notes slides”. Delete it if you don’t want to use it. NEXT:

34 Deadlines & Resources Thank you for committing to speak at TechEd North America 2009, Microsoft’s premier event for IT Professionals and Developers. Below is important information regarding your participation: Important Content Deadlines – submit at the Speaker Portal: https://www.msteched.com/ws https://www.msteched.com/ws April 1 at Noon Upload draft of PPT presentation at the Speaker Portal (you must be registered as a speaker to access it)  Your Session Schedule  Manage Slides, follow instructions for Deck Management. April 1-30 Content Review Process (dry run, speaker training, LCA review, etc.) May 6 at Noon Submit final PPT at the Speaker Portal. Additional changes must be brought onsite and editing charges may apply. YOUR PROMPT FINAL PPT SUBMISSION IS APPRECIATED. Slide Design Resources – located at the Speaker Portal Graphics and Images Library (pictures of arrows, devices, people) Books, Webinars, Websites, and much more to help you build a great deck Licensing information and permission for any third-party photography or art must be credited in the PPT or it will be deleted. Points of Contact Direct presentation questions to tespkr@microsoft.comtespkr@microsoft.com Direct content questions to your Track PM. (contact info is at the speaker portal) This template is designed for use with Office PowerPoint 2007. PRINTING: This template is set to print in color or grayscale, not black and white.

35 Presentation Outline (hidden slide): Title: Technical Level: Intended Audience: Objectives (what do you want the audience to take away from this session): 1. 2. 3. Presentation Outline (including demos): Speakers: complete this slide using the session information found at the speaker portal.

36 Scrub Checklist Your final PPT will be scrubbed and posted to CommNet 48-hours prior to the session. Upload your final deck on or before May 6, 2009 at Noon PST. Apply template – backgrounds, colors, positioning, font Verify that required slides are included Remove any non-template logos and graphics from the walk-in slide Correct session title and session code to match session guide Set titles to Title Case and correct widows (widows = single word spilling over to a new line) Replace transition slides with template transition slides Set subtitles to subtitle color, size, and sentence case Correct all type for consistent shadowing Set bullets to template Set software code samples to template code format Correct template application issues as time allows Correct Microsoft product names to follow corporate branding rules Correct misspelled words Remove all comments, hidden slides and speaker notes from slides Set file properties box Set printability in grayscale If time allows, correct slides for readability and consistency If time allows, correct grammar and correct copy to Microsoft style Notify Presentation Manager of any images identified as unlicensed for escalation

37 Video Title

38 Customer Title Name Title Company

39 Demo Title Name Title Company

40 Partner Title Name Title Company

41 Announcement Title

42 PowerPoint Template Subtitle color Set the slide title in “title case” and subheads in “sentence case” The subhead color is defined for this template as the fourth font color from the left Font Size Requirements Main bullet points must not be smaller than 24pt Do NOT use any font size lower than 20pt Set subhead to 36pt or smaller so it will fit on a single line Turn off Auto Resizing on all text boxes

43 Slide for Showing Software Code Use this layout to show software code The font is Consolas, a monospace font The slide doesn’t use bullets but levels can be indented using the “Increase List Level” icon on the Home menu To use straight quotes " instead of smart quotes ”, do this: 1. Click on the Office Button in the upper left corner 2. At the bottom of the menu, choose PowerPoint Options 3. From the left pane, select Proofing 4. Click on the AutoCorrect Options button 5. Select the AutoFormat As You Type tab, and deselect “Straight quotes” with “smart quotes”. Then Click OK.

44 Table Format Table Title Column 1 Column 2 Column 3 Column 4 Column 5

45 Bar Chart Example

46 Pie Chart Example

47

48 Notes on Required Slides In addition to the Walk-in and Title slides, the following slides are required Please add your content and include these in your final presentation

49 www.microsoft.com/teched Sessions On-Demand & Community http://microsoft.com/technet Resources for IT Professionals http://microsoft.com/msdn Resources for Developers www.microsoft.com/learning Microsoft Certification & Training Resources Resources Required Slide Speakers, TechEd 2009 is not producing a DVD. Please announce that attendees can access session recordings at TechEd Online. Required Slide Speakers, TechEd 2009 is not producing a DVD. Please announce that attendees can access session recordings at TechEd Online. www.microsoft.com/learning Microsoft Certification and Training Resources

50 Related Content Breakout Sessions (session codes and titles) Interactive Theater Sessions (session codes and titles) Hands-on Labs (session codes and titles) Required Slide Speakers, please list the Breakout Sessions, TLC Interactive Theaters and Labs that are related to your session. Required Slide Speakers, please list the Breakout Sessions, TLC Interactive Theaters and Labs that are related to your session.

51 Track Resources Resource 1 Resource 2 Resource 3 Resource 4 Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub.

52 Complete an evaluation on CommNet and enter to win! Required Slide

53 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. Required Slide


Download ppt "Daniel Simmons Dev Manager Microsoft Session Code: DTL401."

Similar presentations


Ads by Google