• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Entity Framework NYC Firestarter
 

Entity Framework NYC Firestarter

on

  • 4,409 views

On Sept 27, 2010, Julie Lerman, Rachel Appel and Steve Bohlen presented a full day of Entity Framework presentations to help developers get started with EF. The presentations begin with "why entity ...

On Sept 27, 2010, Julie Lerman, Rachel Appel and Steve Bohlen presented a full day of Entity Framework presentations to help developers get started with EF. The presentations begin with "why entity framework" and end with creating better architectures when using EF.

Statistics

Views

Total Views
4,409
Views on SlideShare
4,405
Embed Views
4

Actions

Likes
3
Downloads
0
Comments
1

3 Embeds 4

http://www.slashdocs.com 2
http://static.slidesharecdn.com 1
https://bbprod.stjohns.edu 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • plz open it for download
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Entity Framework NYC Firestarter Entity Framework NYC Firestarter Presentation Transcript

    • NYC
      Entity Framework
      Firestarter
    • Speakers
    • Entity Framework Firestarter
      Schedule
    • Thanks Microsoft
      For Hosting and Lunch
    • EF NYC Firestarter
      Part 1: It’s Time to Look at Entity Framework
      Julie Lerman
      thedatafarm.com/blog
      twitter @julielerman
    • Julie Lerman
      website
      theDataFarm.com
      blog & twitter
      theDataFarm.com/blog@julielerman
      book web site
      LearnEntityFramework.com
      consultant/mentor
      Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader
      NYC Entity Framework Firestarter, Sept 27th 2010
    • Why Entity Framework?
      NYC Entity Framework Firestarter, Sept 27th 2010
      Object Relational Mapper
      ADO.NET
      Data
      Set
      ADO
      Record
      Set
      Entity
      Framework
      Object
      Spaces
    • Design Time: EDMX
      EF Metadata vs Other ORMs
      NYC Entity Framework Firestarter, Sept 27th 2010
      DB
      DB
      EF Runtime Metadata (XML files)
      Conceptual Model
      Schema
      Database
      Structure
      Schema
      Designer Layout & Positioning
      Typical ORM
      Objects
    • ADO.NET Today & Tomorrow
      NYC Entity Framework Firestarter, Sept 27th 2010
      DataSet
      Entity Framework
      LINQ to SQL
    • Model in Entity Framework
      Model
      First
      Database
      First
      New
      Database
      Legacy
      Database
      Code
      First
      NYC Entity Framework Firestarter, Sept 27th 2010
      “M”
    • Entity Framework
      Conceptual Model in your Apps
      UI
      DB
      Conceptual
      Model
      of your Domain
      App Logic
      Provider
      Query
      Track Changes
      Repository
      Updates to DB
      Business
      Objects
      NYC Entity Framework Firestarter, Sept 27th 2010
    • Time to Code
      A little modeling…
      A little querying…
      A little editing…
      A little saving…
      NYC Entity Framework Firestarter, Sept 27th 2010
    • FAQS
      Stored Procedure Support
      Use Views & Stored Procs – no table access
      Update the model when DB changes
      Mappings are highly customizable
      Inheritance
      Many to Many
      Merge tables
      Split tables
      etc
      Pass through queries & commands
      NYC Entity Framework Firestarter, Sept 27th 2010
    • Entity Framework Everywhere
      NYC Entity Framework Firestarter, Sept 27th 2010
    • Why Entity Framework Summary
      Microsoft’s in-the-box ORM
      Focus of Microsoft/.NET data access
      Use any back end db (with a provider)
      Use in any type of .NET application
      Backbone of many Microsoft technologies
      NYC Entity Framework Firestarter, Sept 27th 2010
    •  Part 2:What’s new in Entity Framework 4
      EF NYC Firestarter
      Steve Bohlen
      unhandled-exceptions.com/blog
      twitter @sbohlen
    • Long Form: Comprehensive
      NYC Entity Framework Firestarter, Sept 27th 2010
      Model-first development
      Automatic pluralization
      Foreign keys in models
      POCO class support
      Lazy loading
      T4 Code Generation
      Template customization
      IObjectSet
      Virtual SaveChanges
      ObjectStateManagercontrol
      Self-tracking entities
      SQL generation improvements
      More LINQ operator support
      LINQ extensibility
      ExecuteStoreQuery
      ExecuteStoreCommand
      SPROC import improvements
      Model defined functions
      WPF designer integration
      Code-First development (Feature CTP)
    • Short Form: Highlights
      Designer Improvements
      Foreign Keys
      New Code Generation
      Persistence Ignorance
      Change Tracking for WCF
      Better n-tier Support
      Lazy Loading
      Code-Only Development
    • Designer Improvements
      Pluralization Support
      Generate Database from Model
      vs. only Reverse-Engineering in v1
      Improved SPROC Support
      SPROCs can return only entities in v1
      SPROCs can return strongly-typed projections in v4
    • Foreign Key Support
      ERM vs exposed FKs (it’s a CHOICE via the dialog box)
      Does NOT replace the Nav properties
      DataContext is able to leverage this for some efficiencies
      Changing either the FK or the Nav property changes the other value (due to code-gen support)
    • Code Generation
      Model  templates  Classes
      Code Generation Engine now T4 instead of proprietary engine in v1
      Tools support/syntax support resources
      review a quick look at the T4 syntax
      T4 Editor add-in
    • (better) Persistence Ignorance
      EntityObject inheritance NOT required
      Snapshot-based
      No lazy loading support in this approach
      No Change Tracking
      must call ObjectContext.DetectChanges( )
      ObjectContext.Save( ) implicitly calls .DetectChanges( )
      Proxy-based
      virtual keyword is the ‘flag’ for this behavior
      virtual on all  change-tracking and lazy-load
      virtual on just navigation props  only lazy-loading
      Several Canned Templates
    • WCF and Self-Tracking Entities
      T4 template for self-tracking entities
      Passing objects across serialization boundaries
    • Lazy Loading
      v1 supported only explicit load of lazy collections
      ObjectContext.ContextOptions.LazyLoadingEnabled = true
      by default in NEW models, but NOT in imported v1 models
      Behavior scoped at the ObjectContext
      NOT at property level for entities
      Toggle-able before and after operations for query-specific granular lazy-loading behavior
    • Explicit State Management
      ObjectContext.ApplyCurrentValues( )
      Formerly ApplyPropertyChanges( ) in v1
      ObjectContext.ApplyOriginalValues( )
      ObjectStateEntry.ChangeState( )
      Unchanged/Added/Modified/Deleted
      ObjectStateManager.ChangeRelationshipState( )
    • Code-Only Support
      ‘Feature CTP’
      Classes  Entities
      Entities  Database (optionally)
      No Model Necessary
      Heavily Convention over Configuration
    • Miscellaneous
      Model-Defined Functions
      ObjectSet (collections of entities)
      Complex Type Support
      Query optimization (E-SQL, LINQ2Entities)
      ExecuteCommand/Defined Queries/Model Functions
      Designer support for more features without direct editing of .csdl, .ssdl, .edml
    •  Part 4: Getting Started with POCOs in EF4
      EF NYC Firestarter
      Julie Lerman
      thedatafarm.com/blog
      twitter @julielerman
    • Agenda
      Simple POCO Classes
      Leveraging Proxies
      Customizable T4 Code Generation
      NYC Entity Framework Firestarter, Sept 27th 2010
    • POCO
      Plain Old CLR Objects
    • Benefits
      Use existing classes
      Loose Coupling
      Classes have no dependency on EF
      Persistence Ignorance
      Unit Testing
      Repositories & Unit Of Work Patterns
    • ObjectContext Manages Entities
      NYC Entity Framework Firestarter, Sept 27th 2010
      POCO
      “Snapshot”4.0
      EntityObject
      (3.5 & 4.0)
      ObjectContext
      Person Object
      State info
      State info
      Order Object
      State info
      Detail Object
      State info
      Detail Object
      State info
      Order Object
      State info
      Detail Object
      State info
      Detail Object
    • POCO Support Basics
      Turn off code generation from EDMX
      “Convention” will auto-map classes/entities
      NYC Entity Framework Firestarter, Sept 27th 2010
    • POCO and Other EF Features
      Complex Types
      Use a class (no structs) to represent the type
      Explicit Loading
      ObjectContext.LoadProperty(myObj,”PropertyName”)
      ObjectContext.LoadProperty(myObj, o=>o.property)
      Two-Way Navigation
      Must be coded into classes
      NYC Entity Framework Firestarter, Sept 27th 2010
    • Lazy Loading POCOs
      virtual (Overridable) navigation properties
      IRelatedEnd wrapper at run-time
      LazyLoadingEnabled=true required
      Selectively allow lazy loaded properties
      publicList<CreditCard>CreditCards {get; set; }
      virtualpublicPersonPerson {get;set; }
      publicList<Order> Orders { get;set; }
    • ObjectContext Manages Entities
      NYC Entity Framework Firestarter, Sept 27th 2010
      POCO
      “Snapshot”4.0
      POCO
      + Dynamic Runtime Proxy
      (4.0)
      EntityObject
      (3.5 & 4.0)
      ObjectContext
      Person Object
      State info
      State info
      Order Object
      State info
      Detail Object
      State info
      Detail Object
      State info
      Order Object
      State info
      Detail Object
      State info
      Detail Object
    • Dynamic Runtime Proxy Classes
      • Track
      • Lazy Load
      • Relationships
      Person
      class
      F5
      Mark all Entity (model) Properties virtual
      Provides features similar to EntityObject
      Change notification
      Relationship management
      Lazy Loading
    • Rules for Proxy Notification
      All entity properties shall be virtual
      Though shalt use ICollection<T>
      Creation shall be done withObjectContext.CreateObject<T>
      Classes shall not be sealed
      Navigation properties shall not be sealed
      Classes shall not be abstract
      Classes shall have a parameter-less constructor
    • Code Gen POCOs from Model
      T4
      T
      4
      Text Template Transformation Toolkit
    • EF POCO Summary
      POCO support is new to EF4
      Alternative to EntityObjects
      Simple snapshot POCOs or use proxies
      Use or even customize T4 template for code generation
      Enable many coding/architectural possibilities
      NYC Entity Framework Firestarter, Sept 27th 2010
    •  Part 5: Disconnected Strategies for ASP.NET & Services
      EF NYC Firestarter
      Julie Lerman
      thedatafarm.com/blog
      twitter @julielerman
    • Agenda
      EF Challenges in Server Aps
      Review Options with EF
      EF4 Tools to the Rescue
      POCOs and Repositories
      Leveraging Foreign Keys
      Putting it all together
    • Change Tracking Across Tiers
      ObjectContext
      ObjectStateEntry
      SO1 EntityKey Original ValuesCurrent Values Other ∆ Info
      ObjectStateEntry
      SO2 EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info
      detach
      entities
      ObjectStateEntry
      LIA EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info
      Original Property Values
      EntityState Values
      ObjectStateEntry
      LIB EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info
    • SaveChanges Fails Across Post Backs
      Page Request
      Post Back #1
      Post Back #2
      New Page Class
      New Page Class
      New Page Class
      Create New ObjectContext
      Create NewObjectContext
      Create NewObjectContext
      Get Entities
      Process Request
      Get Entities
      Build HTML using Data & ASP.NET Markup
      Build HTML using Data & ASP.NET Markup
      Build HTML using Data & ASP.NET Markup
      Destroy Page and Dependents
      Destroy Page and Dependents
      Destroy Page and Dependents
    • The Server Side Spectrum with EF
      Dynamic Data forEntities
      ObjectDataSource
      WCF &
      Self-Tracking Ents
      EntityDataSource
      MVC
      WCF
      Data
      Services
      Dev
      WCF
      ASP.NET
      n-Tier
      Architect
    • EF4 Changes to the Rescue
      Foreign Keys
      Big help for selected list values on postback
      State Methods
      ApplyCurrentValues, ApplyOriginalValues
      ChangeState
      ChangeRelationshipState (when no FKs)
      POCO Classes & T4 Generation
      Self-Tracking Entities for use with WCF
    • What about?
      Graphs
      Lazy Loading
      Returning IQueryables
      Change
      Tracking
    • NYC Entity Framework Firestarter, Sept 27th 2010
      Oh, goody….
      time for code…
    • Disconnected Strategies Summary
      EF has inherent challenges across tiers
      New tools in EF4 to enable disconnected
      NYC Entity Framework Firestarter, Sept 27th 2010
    •  Part 6:Writing Testable/Maintainable Apps with EF
      EF NYC Firestarter
      Steve Bohlen
      unhandled-exceptions.com/blog
      twitter @sbohlen
      Julie Lerman
      thedatafarm.com/blog
      twitter @julielerman
    • Agenda
      Setting the stage
      Refactor a demo-worthy MVC app
      Explore an existing solution with more complexity
    • “-ilities”
      Benefits:
      Extensibility
      Adaptability
      Testability
      Maintainability
      Quality 
      Why should You Care?
      Persistence Ignorance (PI)
      Future-Proofing your investment
      NYC Entity Framework Firestarter, Sept 27th 2010
    • IObjectSet Abstraction
      IObjectSet
      Collection-like behavior
      Add, Attach, Delete, etc.
      ObjectSet
      Concrete class
      Implements IObjectSet
      Inherits ObjectQuery
      public class ObjectSet:ObjectQuery,IObjectSet
    • EF4 Goodness Makes This Work
      NYC Entity Framework Firestarter, Sept 27th 2010
      POCOs
      +
      T4 Code Gen
      Disconnected Methods
      IObjectSet
    • Classes
      PI/Repositories
      System.Data.Entity
      Fake
      ObjectSet
      Fake
      Context & Data A
      EDM &
      ObjectContext
      Fake
      Context & Data B
      Unit of Work
      Class
      Repositories
      Class
      Repositories
      Class
      Repositories
      Repositories
      UI
      Tests
    • Resources
      LearnEntityFramework.com/resources
      thedatafarm.com/blog/tags/ef4
      blogs.msdn.com/adonet, efdesign, dsimmons, alexj, more...
      msdn.microsoft.com/data
      Gateway to whitepapers, forums, documentation
      Lots of bloggers on EF now! Google! 
      -Bing!
      NYC Entity Framework Firestarter, Sept 27th 2010