Building nTier Applications with Entity Framework Services (Part 1)


Published on

Learn how to build real world nTier applications with the new Entity Framework and related services. 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. The session will demonstrate how to create and consume these new technologies from the ground up and focus on database modeling including views and stored procedures along with coding against the model via LINQ. Dynamic data website will also be demonstrated.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
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
  • Demo: AdventureWorks.DataDemo: AdvertureWorks.ExampleDemo: EntityDesignerDiagram.png
  • Building nTier Applications with Entity Framework Services (Part 1)

    1. 1. Building nTier Applications with Entity Framework ServicesPart 1<br />
    2. 2.
    3. 3. Check Out Your Local User Groups!<br />San Diego Cloud Computing User Group<br /><br />San Diego .NET Developers Group<br /><br />San Diego .NET User Group<br /><br />San Diego SQL Server User Group<br /><br />
    4. 4. Win Free Software!<br />Rules<br />Provide your business card (or email and name)*<br />Indicate on the back what software you are interested in<br />Otherwise I will pick <br />Winners will be picked next week<br />*Yes, most likely I’m going to send you and email about my user group ( and or web site (<br />Prizes<br />CodeRush and Refactor Pro from DevExpress (4)<br />SecondCopy (automatic backup software) (5) *<br />CodeIt.Right Standard from SubMain (4)<br />*Requires mailing address and phone number<br />
    5. 5. Agenda<br />
    6. 6. Overview<br />
    7. 7. 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 />
    8. 8. User Experience<br />Security<br />Active Directory, Card Space, Windows Identity Foundation<br />UI Components<br />Windows Forms, Windows Presentation Foundation, ASP.NET (AJAX, MVC), Silverlight, Windows Mobile<br />Presentation Layer<br />Local Storage/ Cache<br />Communications Layer<br />Windows Communication Foundation (WCF), WCF Data Services, Web Services, Sync Services, Azure (Cloud), RIA Services, Workflow Services<br />Business Layer<br />Business Entities<br />T4 Templates<br />Business Components<br />Business Workflow<br />Windows Workflow Foundation<br />Data Layer<br />Entity Framework, LINQ to SQL, DataSets<br />SQL Server<br />
    9. 9. Entity Framework<br />
    10. 10. 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 />
    11. 11. Object Relational Mapping<br />It’s nothing new, just new to .NET<br />There are many ORMs for .NET developers already in existence. E.g.<br />LLBLGen Pro<br />Nhibernate<br />EntitySpaces<br />
    12. 12. 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 />
    13. 13. 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 />
    14. 14. ADO.NET Entity Framework<br />
    15. 15. EF Providers in Progress<br />
    16. 16. LINQ to Entities – Lots of Topics<br />
    17. 17.
    18. 18. 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 />
    19. 19. Fixing the Paint Points in EF1<br />Advanced/ New Features<br />
    20. 20. Model First<br />Create your conceptual model first (not from an existing database)<br />Wizard will allow the creation of sql scripts to create database scripts.<br />Also will create EDM files<br />Creates SQL Server, SQL Server Express, SQL Server Compact database scripts.<br />
    21. 21. Lazy Loading<br />Enables retrieving all related data (without asking for it)<br />Off by default<br />Settable on the ContextOptions<br />Good for doing reporting!<br />Not great for going across services<br /> Dim ctx As New AdventureWorksLT_DataEntities()<br />ctx.ContextOptions.LazyLoadingEnabled = True<br />
    22. 22. T4 Templates<br />Override default EF classes to create…<br />POCO Entity Generator<br />Better for going over RESTful service layers<br />Self-Tracking Entity Generator<br />Better for server/ client local storage.<br />Auto generates classes when models change!<br />Or can be run manually.<br />Easily modifiable for your own needs<br />Once you learn the T4 scripting language.<br />
    23. 23.
    24. 24. Summary<br />
    25. 25. Conclusion<br />
    26. 26. Resources<br />ADO.NET Team Blog<br /><br />EF Design Blog<br /><br />Visual Studio Data Blog<br /><br />dnrTV!<br /><br /><br />
    27. 27. Resources<br />Dan Simmons Blog<br /><br />MSDN Code Gallery<br /><br />WCF Data Services Learning Guide:<br /><br />WCF Data Services Team Blog<br /><br />
    28. 28. Required Book!<br />EF4 In Aug 2010<br />