Building N Tier Applications With Entity Framework Services 2010

9,324 views

Published on

Learn how to build real world nTier applications with the new Entity Framework and related services introduced in .NET 3.5 SP1. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up. Lots of code!

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

No Downloads
Views
Total views
9,324
On SlideShare
0
From Embeds
0
Number of Embeds
198
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • Goals:To show a new way of serving up dateGet you thinking to learn more when you leave this presentation
  • How do you or have you designed your applications??? Be truthful!!N-tier application architecture provides a model for developers to create a flexible and reusable application. By breaking up an application into tiers, developers only have to modify or add a specific layer, rather than have to rewrite the entire application over, if they decide to change technologies or scale up. In the term "N-tier," "N" implies any number -- like 2-tier, or 4-tier; basically, any number of distinct tiers used in your architecture. Application architectures are part of Layer 7 of the OSI model.
  • Talk about the separation between database developer and programmer.
  • Talk about the separation between database developer and programmer.
  • Applications can work in terms of a more application-centric conceptual model, including types with inheritance, complex members, and relationships.Applications are freed from hard-coded dependencies on a particular data engine or storage schema.Mappings between the conceptual model and the storage-specific schema can change without changing the application code.Developers can work with a consistent application object model that can be mapped to various storage schemas, possibly implemented in different database management systems.Multiple conceptual models can be mapped to a single storage schema.Language-integrated query (LINQ) support provides compile-time syntax validation for queries against a conceptual model.
  • POCO = Plane Old .NET Classes
  • Demo: AdventureWorks.DataDemo: AdvertureWorks.ExampleDemo: EntityDesignerDiagram.png
  • AdventureWorks.AdminAdd entity referenceAdd Reference to System.Data.EntityAdd connection string to web.configShow ProductCategories table.
  • Talk about any object can be exposed via EF!
  • Demo: AdvertureWorksServiceDemo: AdventureWorks.Client
  • Building N Tier Applications With Entity Framework Services 2010

    1. 1. Building nTier Applications with Entity Framework Services<br />
    2. 2.
    3. 3. Agenda<br />
    4. 4. Overview<br />
    5. 5. nTier Architecture Overview<br />Model to create flexible reusable applications<br />Only need to modify or add layers instead of rewriting entire applications over<br />
    6. 6. Where’s Your Data Model?<br />Applications Today…<br />Implicitly Contain the Data Model<br />Logic and Model Intertwined<br />Conceptual Mismatch<br />Often encapsulate in a "Data Access Layer"<br />
    7. 7. Where’s Your Data Model?<br /><ul><li>What Is Really Needed
    8. 8. Applications work with a well Defined Model
    9. 9. Storage Schema Abstraction
    10. 10. Declarative mapping between application and storage models
    11. 11. No brittle, hard-coded mapping</li></li></ul><li>Entity Framework<br />
    12. 12. Object Relational Mapping<br />What is ORM?<br />Technique for working with relational tables as if they were objects in memory<br />Intention is to hide away the complexity of the underlying tables and give a uniform way of working with data<br />Why use ORM?<br />Productivity<br />Retain database independence<br />ObjectsClassesEntities<br />
    13. 13. Object Relational Mapping<br />There are many ORMs for .NET developers already in existence. E.g.<br />LLBLGen Pro http://www.llblgen.com/<br />Nhibernate http://www.hibernate.org/343.html<br />EntitySpaces http://www.entityspaces.net/Portal/Default.aspx<br />
    14. 14. The Microsoft Entity Data Model<br />An extended relational model with Entity-Relationship Model concepts<br />Entity Types<br />Strong type with Identity<br />Inheritance<br />Scalar/Complex properties<br />EntitySets<br />Hold instances of Entity Types<br />Similar to relational tables<br />Can have multiple Entitysets of the same EntityTypes<br />Relationships ("Associations")<br />Named relationships between Entities<br />0..1:*, 0..1:0..1, 1:1, 1:M, M:N<br />Navigation may be exposed as NavigationProperties on EntityTypes<br />AssociationSets<br />Contains instances of associations<br />May be queried directly<br />EntityContainers<br />Contains EntitySets, AssociationSets<br />SalesPerson<br />EmployeeID = 294272LoginID = adamTitle = "Dev Lead"VacationHours = 0…<br />Manager<br />1<br />1<br />N<br />Reports<br />SalesPerson<br />SalesPerson<br />EmployeeID = 729742LoginID = peteTitle = "Developer"VacationHours = 0…ExpenseAccount = …CarLicenseNum = ……<br />SalesPerson<br />EmployeeID = 729742LoginID = peteTitle = "Developer"VacationHours = 0…ExpenseAccount = …CarLicenseNum = ……<br />EmployeeID = 729742LoginID = peteTitle = "Developer"VacationHours = 0…ExpenseAccount = true…<br />
    15. 15. EDM & Entity Framework?<br />The Entity Framework (EF) is an Object Relational Modeling tool leveraging the EDM<br />Focus on your domain, not how to persist!<br />EDM is used to describe your model.<br />Allows different rate of change between database and code!<br />EF uses a storage model and mapping to enable this.<br />
    16. 16. ADO.NET Entity Framework<br />
    17. 17. EF Providers in Progress<br />
    18. 18. LINQ to Entities – Lots of Topics<br />
    19. 19.
    20. 20. Using Entity Framework with ASP.NET<br />
    21. 21. Pain Points in v3.5 SP1<br />Pluralization/ Singularization<br />Foreign Keys<br />Model First<br />Lazy Loading<br />Additional LINQ Operators<br />L2S Features & Patterns<br />SQL Gen Improvements<br />
    22. 22. Entity Framework in .NET 4<br />Improvements:<br />Model First<br />T4 Templates to control code generation<br />Supporting DDD approach with POCO <br />Persistence Ignorance<br />Repository pattern<br />Query Improvements<br />Lazy Loading<br />Disconnected API’s to enable N-tier <br />
    23. 23. Easily Expose Your Entities<br />WCF Data Services<br />
    24. 24. Data Services Overview<br />Extends Windows Communication Foundation<br />Functionality<br />CRUD access to data over RESTful web services<br />Built-in URI-based query syntax<br />Client-side libraries for .NET and AJAX clients<br />
    25. 25. Data Services<br />HTTP<br />Open Data Protocol<br />Hosting/HTTP Listener<br />Data Services Runtime<br />IQueryable/IEnumerable<br />[+ IUpdatable]<br />Data Access Layer<br />Entity Framework<br />Custom LINQ Provider<br />Relational database<br />Other sources<br />
    26. 26. Data Services - A REST Interface<br /><ul><li>The underlying model
    27. 27. Entities and associations  resources and links</li></li></ul><li>WCF 4<br />Programming Model<br />Core Services<br />Web HTTP Services<br />Data Services<br />RIA Services<br />Workflow Services<br />Service Model<br />Data Contract<br />Service Contract<br />Service Behavior<br />Channel Model<br />Formats<br />(Atom, JSON, XML,…)<br />Transports<br />(HTTP, TCP, …)<br />Protocols<br />(SOAP, HTTP, Open Data Protocol,…)<br />
    28. 28. URL Conventions<br />Addressing entities and sets<br /><ul><li>Presentation options</li></li></ul><li>Modern Data-Driven Web Apps<br />AJAX integration<br />AJAX-friendly JSON format in services<br />Javascript library that integrates with the ASP.NET AJAX toolkit<br />Silverlight support<br />.NET programming model for data services<br />Object based, LINQ enabled API<br />Code-gen entity types from metadata<br />
    29. 29. "Traditional" Applications<br />Web applications<br />Data services client can be used in ASP.NET<br />ASP.NET data source control for accessing remote services<br />Desktop applications<br />Fully-featured .NET client library<br />Same API in desktop and Silverlight environments<br />
    30. 30. What’s New in .NET 4<br />Data Binding<br />New DataServiceCollection class provides simplified binding of data service data to (WPF) controls. Includes auto updating.<br />Counting Entities in an Set <br />$count - total number of resources returned by a URI<br />$inlinecount - total resource count together with the resource data<br />Server-driven Paging <br />Service can be configured to return requested resources as a set of paged responses<br />
    31. 31. What’s New in .NET 4<br />Query Projections<br />Query results can be modified to include only a subset of properties by using the new $select query option.<br />Custom Data Service Providers<br />Can implement a set of new data service provider interfaces, you can use various types of data with a data service, even when the data model changes during execution.<br />Streaming of Binary Resources<br />This enables you to retrieve and save binary large object data independent of the entity to which it belongs.<br />
    32. 32.
    33. 33. Summary<br />
    34. 34. Conclusion<br />
    35. 35. Before You Begin…<br />What I Have Learned So Far About The Entity Framework and ADO.NET Data Services<br />http://dotnettips.com/2008/09/30/WhatIHaveLearnedSoFarAboutTheEntityFrameworkAndADONETDataServices.aspx<br />*Part 2 coming out soon!<br />Using Microsoft ADO.NET Data Services<br />http://msdn.microsoft.com/en-us/library/cc907912.aspx<br />
    36. 36. Resources<br />ADO.NET Team Blog<br />http://blogs.msdn.com/adonet/default.aspx<br />EF Design Blog<br />blogs.msdn.com/efdesign<br />Visual Studio Data Blog<br />http://blogs.msdn.com/vsdata/<br />dnrTV!<br />http://shrinkster.com/1734<br />http://shrinkster.com/1735<br />
    37. 37. Resources<br />Dan Simmons Blog<br />http://blogs.msdn.com/dsimmons/<br />MSDN Code Gallery<br />http://shrinkster.com/1733<br />WCF Data Services Learning Guide:<br />http://msdn.microsoft.com/en-us/data/bb931106.aspx<br />WCF Data Services Team Blog<br />http://blogs.msdn.com/astoriateam/default.aspx<br />
    38. 38. Required Book!<br />

    ×