Building nTier Applications with Entity Framework Services<br />
dotNetDave Conference DVD!<br />Packed full of:<br />Videos of all sessions from 2010 & 2011(1)!<br />Slide decks from 201...
Check Out Your Local User Groups!<br />San Diego Cloud Computing User Group<br />www.azureusergroup.com/group/sandiegoazur...
Agenda<br />
Overview<br />
Where’s Your Data Model?<br />Applications Today…<br />Implicitly Contain the Data Model<br />Logic and Model Intertwined<...
Where’s Your Data Model?<br /><ul><li>What Is Really Needed
Applications work with a well Defined Model
Storage Schema Abstraction
Declarative mapping between application and storage models
No brittle, hard-coded mapping</li></li></ul><li>User Experience<br />Security<br />Active Directory, Card Space,  Windows...
Object Relational Mapping<br />
The Dilemma<br />Software Architects & Developers<br />Database Designers & Administrators<br />
 Object Relational Mapping<br />What is ORM?<br />Technique for working with relational tables as if they were objects in ...
 Object Relational Mapping<br />Why use ORM?<br />Productivity<br />Retain database independence<br />Database portability...
Many attempts<br />Typed Datasets<br />Objectspaces ‘v1’<br />Objectspaces ‘v2’<br />Microsoft Business Framework<br />Win...
Entity Framework<br />
The Microsoft Entity Data Model<br />An extended relational model with Entity-Relationship Model  concepts<br />Entity Typ...
EDM & Entity Framework?<br />The Entity Framework (EF) is an Object Relational Modeling tool leveraging the EDM<br />Focus...
IEnumerable<T><br />LINQ to Entities<br />Entity SQL Query<br />Object Services<br />EDM<br />DataReader<br />Entity SQL<b...
Performance & Security?<br />Connections to database vs. amount of data<br />You can work with stored procedures <br />You...
Entity Framework in .NET 4<br />Model First<br />T4 Templates to control code generation<br />Supporting DDD approach with...
Easily Expose Your Entities<br />WCF Data Services<br />
WCF Data Services Overview<br />Framework from Microsoft that that facilitates the creation of RESTful data services via H...
WCF Data Services Overview<br />Automates the exposure of data as RESTful resources<br />Anything that implements IQueryab...
HTTP<br />http://localhost:1234/MyData.svc/MyEntities(10)<br />Open Data Protocol (OData)<br />Hosting/HTTP Listener<br />...
Data Services - A REST Interface<br /><ul><li>The underlying model
Entities and associations  resources and links</li></li></ul><li>URL Conventions<br />Addressing entities and sets<br /><...
WCF Data Services in .NET 4<br />Query Projections<br />Query results can be modified to include only a subset of properti...
Summary<br />
Resources<br />ADO.NET Team Blog<br />http://blogs.msdn.com/adonet/default.aspx<br />EF Design Blog<br />blogs.msdn.com/ef...
Resources<br />ADO.NET team blog<br />http://blogs.msdn.com/adonet<br />WCF Data Services team blog<br />http://blogs.msdn...
Upcoming SlideShare
Loading in...5
×

Building nTier Applications with Entity Framework Services

3,414

Published on

Learn how to build real world nTier applications with the 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. 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.

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

No Downloads
Views
Total Views
3,414
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
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
  • Maintainabity, security, efficiency andscalability let a DBA decideto:Splitdata of oneentityintoseveraltablesPutting data forseveral types of entitiesintosametableSupply projectionsthatlooseentity concepts thatmight have been present in tablestructures
  • Talk about the separation between database developer and programmer.
  • Talk about the separation between database developer and programmer.
  • Typed Datasets – shippedObjectspaces ‘v1’ – never shippedObjectspaces ‘v2’ – never shippedMicrosoft Business Framework – never shippedWinFS – never shippedLinq to SQL – shipped, won’t be discontinuedLinq to Entities – shippedEntity Framework- shipped 
  • 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.
  • Explain the inner workings of the entity framework Three types of commands: LINQ to Entities against Object Services Materialization to Conceptual model classes or anonymous classes if projected Entity Sqlagaints Object Services Materialization if no projection + streamed data on row level Call model defines functions or specific Entity SQL functions. Entity Sql against Entity Client No materialization + streamed data on column levelExplain the path of commands…
  • http://www.robbagby.com/entity-framework/is-lazy-loading-in-ef-4-evil-or-the-second-coming/
  • Demo: AdventureWorks.DataDemo: AdvertureWorks.ExampleDemo: EntityDesignerDiagram.png
  • Demo: AdvertureWorksServiceDemo: AdventureWorks.Client
  • Building nTier Applications with Entity Framework Services

    1. 1. Building nTier Applications with Entity Framework Services<br />
    2. 2.
    3. 3. dotNetDave Conference DVD!<br />Packed full of:<br />Videos of all sessions from 2010 & 2011(1)!<br />Slide decks from 2011 & 2010!<br />Demo projects from 2011 & 2010!<br />David McCarter’s .NET interview Questions!<br />Extras<br />Conference Photos from 2010!<br />Surprise videos!<br />Book + DVD $25!<br />Only $15!<br />
    4. 4. Check Out Your Local User Groups!<br />San Diego Cloud Computing User Group<br />www.azureusergroup.com/group/sandiegoazureusergroup<br />San Diego .NET Developers Group<br />www.sddotnetdg.org<br />San Diego .NET User Group<br />www.sandiegodotnet.com<br />San Diego SQL Server User Group<br />www.sdsqlug.org<br />
    5. 5. Agenda<br />
    6. 6. Overview<br />
    7. 7. 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 />
    8. 8. Where’s Your Data Model?<br /><ul><li>What Is Really Needed
    9. 9. Applications work with a well Defined Model
    10. 10. Storage Schema Abstraction
    11. 11. Declarative mapping between application and storage models
    12. 12. No brittle, hard-coded mapping</li></li></ul><li>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 />
    13. 13. Object Relational Mapping<br />
    14. 14. The Dilemma<br />Software Architects & Developers<br />Database Designers & Administrators<br />
    15. 15. 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 />
    16. 16. Object Relational Mapping<br />Why use ORM?<br />Productivity<br />Retain database independence<br />Database portability<br />Objects ► Classes ► Entities<br />
    17. 17. Many attempts<br />Typed Datasets<br />Objectspaces ‘v1’<br />Objectspaces ‘v2’<br />Microsoft Business Framework<br />WinFS<br />Linq to SQL<br />NHibernate<br /> Will “RIP”<br /> Not Microsoft’s<br />
    18. 18. Entity Framework<br />
    19. 19. 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 />
    20. 20. 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 />
    21. 21. IEnumerable<T><br />LINQ to Entities<br />Entity SQL Query<br />Object Services<br />EDM<br />DataReader<br />Entity SQL<br />Conceptual Model<br />Mapping<br />Entity Data Provider<br />DataReader<br />SQL<br />Storage Model<br />ADO.NET Data Provider<br />EF Model<br />
    22. 22. Performance & Security?<br />Connections to database vs. amount of data<br />You can work with stored procedures <br />You can work with views<br />You can define how the ADO.NET Entity Framework loads your data to <br />Eager <br />Lazy<br />(Explicit)<br />
    23. 23.
    24. 24.
    25. 25. Entity Framework in .NET 4<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 />
    26. 26. Easily Expose Your Entities<br />WCF Data Services<br />
    27. 27. WCF Data Services Overview<br />Framework from Microsoft that that facilitates the creation of RESTful data services via HTTP endpoints<br />Shipped with .NET 3.5 SP1<br />Updates for 3.5 SP1 and .NET 4.0<br />Built on top of WCF4<br />Data representation in ATOM or JSON<br />
    28. 28. WCF Data Services Overview<br />Automates the exposure of data as RESTful resources<br />Anything that implements IQueryable<T> and IUpdatable<T><br />Entity Framework<br />3rd party ORMs<br />LINQ to SQL, custom data driven CLR classes<br />Custom URI based querying<br />
    29. 29. HTTP<br />http://localhost:1234/MyData.svc/MyEntities(10)<br />Open Data Protocol (OData)<br />Hosting/HTTP Listener<br />Data Services Runtime<br />var q = from e in MyEntities where id = 10 select e;<br />Data Access Layer<br />Entity<br />Framework<br />Custom LINQ Provider<br />SELECT * FROM MyEntity WHERE id = 10<br />Relational Database<br />Other Sources<br />
    30. 30. Data Services - A REST Interface<br /><ul><li>The underlying model
    31. 31. Entities and associations  resources and links</li></li></ul><li>URL Conventions<br />Addressing entities and sets<br /><ul><li>Presentation options</li></li></ul><li>WCF Data Services 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 />
    32. 32. WCF Data Services 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 />
    33. 33.
    34. 34.
    35. 35. Summary<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 />ADO.NET team blog<br />http://blogs.msdn.com/adonet<br />WCF Data Services team blog<br />http://blogs.msdn.com/astoriateam<br />
    38. 38. Required Book!<br />

    ×