Download presentation
Presentation is loading. Please wait.
Published byBlaze Stewart Modified over 8 years ago
1
DAT303 - Entity Framework: Application Patterns Pablo Castro Technical Lead, Microsoft Corporation
2
Session Prerequisites.NET Framework basics ADO.NET Entity Framework basics In TechEd: DAT201 - Entity Framework Introduction Creation of applications with relational databases
3
Session Objectives and Agenda Session goal: describe concrete application scenarios for the Entity Framework Brief Introduction to the Entity Framework Starting simple: 2-tier applications Getting real: web applications Getting fancy: n-tier applications and services
4
The ADO.NET Entity Framework The next layer up in the ADO.NET stack Describe your data using a conceptual model, we’ll do the rest Entity Data Model design tools Declarative mapping to the database Generation of.NET classes for your business entities Query using LINQ and Entity SQL Handle updates automatically, SQL-gen or stored-procedures
5
2-Tier Applications When? Small applications and tools Trusted clients Application types Windows applications using data-binding Single-task console applications UI and application logic Database server, may include some logic Entity Framework
6
Aspects to Consider Leveraging features Entity Framework has data-binding support built-in Identity resolution maintains object identity in long-running applications Be careful with… Sharing a single context object makes code simpler… …but you need to recycle it or prune it periodically Stale data in the client, concurrency violations more likely
7
Web Applications When? Data-driven web applications Database can be used directly by web application Characteristics Most logic runs in web server Entity Framework used in web server UI in web browser Database server Entity Framework UI rendering + business logic
8
Aspects to Consider Usage patterns Short-lived contexts, create a new one every page hit If absolutely needed, round-trip entities in ASP.NET view state Leveraging features Query results work well with data-aware controls Turn-off object tracking if not going to make changes Query-caching/pre-compilation will speed up execution and lower CPU utilization Web application-friendly connection string syntax Things to avoid Do not store context/connections in application-/session-state
9
Service/Business Logic Tier Data Tier Consumers/Presentation Tier Service contract Multi-Tier Applications When? Medium to large enterprise applications Characteristics Strong UI/business logic separation Enables service- orientation Enables re-use of services and components UI in web browser Entity Framework Desktop application Web server
10
Strict Contracts Style Typically SOAP-based web services interface WCF is the best tool for this Client proxies automatically generated for consuming apps Entity types may or may not be appropriate Sometimes it is better to have separate service types State management can be tricky Service calls need to re-build state before calling into the Entity Framework Use ObjectContext.Attach()/.Attach()
11
Flexible Data Interfaces Style Exposes the data in a more flexible way, at the expense of a less strict contract Use ADO.NET Data Services framework a.k.a. “Project Astoria” Data is exposed over HTTP Each entity becomes a resource URIs are used to point to data (both read and write if enabled) Clients for.NET, Silverlight and Javascript available Or plain HTTP can be used for broader reach
12
Features to Round it up This sessions discussed patterns, not features Some key features commonly applied to real-world scenarios Flexible mapping capabilities, declarative and query-based Stored-procedures support for data retrieval and update Integration with System.Transactions Provider model for multiple database support Graphical tools for authoring models and mappings
13
Summary The ADO.NET Entity Framework automatically generates a data-access layer from a conceptual model Each application scenario has its specific requirements, and the Entity Framework provides the building blocks to handle them
14
Q&A
15
Related Content Breakout Sessions DAT201 Entity Framework Introduction DAT312 Programming SQL Server 2008 WEB313 Project Astoria: Data Services for the Web TLA308 LINQ to SQL: Accessing Relational Data with Language Integrated Query TLA326 LINQ to Entities – Use LINQ to access ADO.NET Entity Data Models Interactive Sessions DAT01-IS Tell Us Where it Hurts! SQL Server Product Feedback Discussion TLA06-IS LINQ to “X”, ADO.NET Entity Framework, DataSets & Co – What is it with all these Data Access Technologies?
16
Resources Data Team site in MSDN http://msdn.microsoft.com/data http://msdn.microsoft.com/data ADO.NET Team blog http://blogs.msdn.com/adonet http://blogs.msdn.com/adonet My blog http://blogs.msdn.com/pablo
17
Resources Technical Communities, Webcasts, Blogs, Chats & User Groups http://www.microsoft.com/communities/default.mspx http://www.microsoft.com/communities/default.mspx Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx http://www.microsoft.com/learning/default.mspx Microsoft Developer Network (MSDN) & TechNet http://microsoft.com/msdn http://microsoft.com/technet http://microsoft.com/msdn http://microsoft.com/technet Trial Software and Virtual Labs http://www.microsoft.com/technet/downloads/trials/defa ult.mspx http://www.microsoft.com/technet/downloads/trials/defa ult.mspx New, as a pilot for 2007, the Breakout sessions will be available post event, in the TechEd Video Library, via the My Event page of the website Required slide: Please customize this slide with the resources relevant to your session MSDN Library Knowledge Base Forums MSDN Magazine User Groups Newsgroups E-learning Product Evaluations Videos Webcasts V-labs Blogs MVPs Certification Chats learn support connect subscribe Visit MSDN in the ATE Pavilion and get a FREE 180-day trial of MS Visual Studio Team System!
18
Complete your evaluation on the My Event pages of the website at the CommNet or the Feedback Terminals to win!
19
© 2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.