Entity Framework 4
Upcoming SlideShare
Loading in...5
×
 

Entity Framework 4

on

  • 1,436 views

 

Statistics

Views

Total Views
1,436
Views on SlideShare
1,418
Embed Views
18

Actions

Likes
0
Downloads
4
Comments
0

2 Embeds 18

http://www.linkedin.com 16
https://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Say word/two about each topic
  • What does ORM mapping do ?Custom classes as entity representing proxy do DBPOCO acronym non persistent classes
  • Unreadable code, bad programming style,bugish code.
  • No notice on using stored proc, security holes opened in application.
  • Unclear DDL logic
  • Programming speed.
  • DB easy switching, less time spent with multiplatform issues, less code.http://blogs.msdn.com/adonet/archive/2007/12/17/the-ado-net-entity-framework-not-just-for-sql-server.aspx
  • Less time getting nervous with debugging app-to-rdbm queries.
  • What can go wrong? Problem:Schema specified is not valid. Errors: The relationship ’DB’. 'Entity' was not loaded because the type 'DB’.’SecondEntity' is not available. Solution:Naming mistakes, check if class properties are same as in the Entity Model
  • Usually used when using web services.Definition of a new behavior attribute that will implement data serialization from proxy to known typeDataContractSerializer and ProxyDataContractResolverDataContractSerializer is instructed how so resolve proxy types.
  • Usually used when using web services.Definition of a new behavior attribute that will implement data serialization from proxy to known typeDataContractSerializer and ProxyDataContractResolverDataContractSerializer is instructed how so resolve proxy types.
  • Usually used when using web services.Definition of a new behavior attribute that will implement data serialization from proxy to known typeDataContractSerializer and ProxyDataContractResolverDataContractSerializer is instructed how so resolve proxy types.

Entity Framework 4 Entity Framework 4 Presentation Transcript

  • EF4 through POCO
    11.02.2010
    Marjan Nikolovski
  • Agenda
    Page 2
    Date: 11.02.2010
    Author: Marjan Nikolovski
    • Introduction
    • Installation
    • Getting started
    • Loading entity properties
    • Tracking changes
    • Working with proxy enabled data
    • Serialization of proxy objects for WCF usage
    • Technology performance
    • Pros and Cons
  • Introduction
    Page 3
    Date: 11.02.2010
    • Yet Another ORM tool ?
    • Custom classes as data proxy
    • POCO acronym
    • Before and Now
    Author: Marjan Nikolovski
  • Yet Another ORM tool ?
    Date
    Page 4
    Author
    • How it is different from the previous known
    • POCO vs. nHybernate, nHydrate, LINQ-SQL
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 5
    Author
    POCO acronym
    • Plain Old CLR Object
    • Acronym for non-persistant data (persistant ignorant)
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Before
    Date
    Page 6
    Author
    • Unreadable code
    • Bad programming style
    • Almost no extensible designs
    • Lot of bugs
    • Knotted logic
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 7
    Author
    Before
    • Forgotten CRUD principles
    • Security issues
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 8
    Author
    Before
    • Unclear DDL/BLL logic
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • EF4 POCO now offers you:
    Date
    Page 9
    Author
    • Efficiency
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 10
    Author
    EF4 POCO now offers you:
    • Easy DB switching
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 11
    Author
    EF4 POCO now offers you:
    • Less time getting nervous with debuggingqueries.
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Installation
    Date
    Page 12
    Author
    • Visual Studio 2010 beta 2
    • ADO.NET Entity Framework Feature Community Technology Preview 2
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Getting started
    Date
    Page 13
    Author
    • Mapping requirements
    • DB mapping and POCO class generation
    • POCO code generator
    • Classes handcrafting
    • Data model to physical model
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 14
    Author
    Mapping requirementsGetting started
    • Custom data class must not be non inheritable, abstract or private
    • Custom data class must have a public parameter less constructor
    • For lazy loading custom data class navigational properties must be defined as overrideable (virtual).
    • Classes must not have any mapping attributes and must not implement IEntityWithChangeTrackeror IEntityWithRelationships interfaces.
    • ProxyCreationEnabled in the ObjectContext’sContextOptions must be set to true (default is true) for ObjectContext tracking.
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 15
    Author
    Mapping requirementsDB mapping and POCO class generation
    • Add Entity Model
    • Mapping DB to Model
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 16
    Author
    Mapping requirementsDB mapping and POCO class generation
    Remove custom tool
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 17
    Author
    Mapping requirementsDB mapping and POCO class generationClasses handcrafting
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 18
    Author
    Mapping requirementsDB mapping and POCO class generationClasses handcrafting
    Create DB Context
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 19
    Author
    Mapping requirementsDB mapping and POCO class generationClasses handcrafting
    In practice
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Date
    Page 20
    Author
    Mapping requirementsData model to physical model
    • Same protocol used descripted above only bottom up strategy used
    • Create sql script
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Loading entity navigational properties
    Date
    Page 21
    Author
    • Navigational properties
    • Explicit loading
    • Lazy loading
    • Eager loading
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Loading entity navigational propertiesExplicit loading
    Date
    Page 22
    Author
    Lazy loading property in Object Context class must be set to false
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Loading entity navigational propertiesLazy loading
    Date
    Page 23
    Author
    Lazy loading property in Object Context class must be set to true
    in order set auto navigation data loading
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Loading entity navigational propertiesEager loading
    Date
    Page 24
    Author
    Eager loading is done by calling include method in LINQ query
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Tracking changes
    Date
    Page 25
    Author
    • Proxy enabled mapping
    • Sharpshooting (self organized tracking)
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Tracking changesProxy enabled mapping
    Date
    Page 26
    Author
    • Automatic tracking of changes in the Context
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Tracking changesSharpshooting (self organized tracking)
    Date
    Page 27
    Author
    • Manual tracking of changes in the Context
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Working with proxy enabled data
    Date
    Page 28
    Author
    • Enabling proxy enabled mapping and data manipulation
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Working with proxy enabled dataEnabling proxy enabled mapping and data creation
    Date
    Page 29
    Author
    • ProxyCreationEnable property must be set to true
    • Creation of entity as proxy types
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Serialization of proxy objects for WCF usage
    Date
    Page 30
    Author
    • What has to be done ?
    • One side implementation
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Serialization of proxy objects for WCF usageWhat has to be done ?
    Date
    Page 31
    Author
    • Proxy object are objects of not known type
    • Defining service behavior where DataContractSerializer must be set in order proxy data to be resolved to known type
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Serialization of proxy objects for WCF usageOne side implementation
    Date
    Page 32
    Author
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Technology performance
    Date
    Page 33
    Author
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Pros and Cons
    Date
    Page 34
    Author
    • Object simplicity and great extensibility
    • Speeding up DAL design and implementation
    • Manual context synchronization can be tricky when comes to business logic
    • Class construction overhead and memory overflow may occur when no proper handling is used
    Author: Marjan Nikolovski
    Date: 11.02.2010
  • Page 35
    Date: 11.02.2010
    Author: Marjan Nikolovski
    Q&A
  • Page 36
    Date: 11.02.2010
    Author: Marjan Nikolovski
    References
    • http://thedatafarm.com/blog/data-access/agile-entity-framework-4-repository-part-1-model-and-poco-classes/
    • http://www.code-magazine.com/Article.aspx?quickid=0909081
    • http://byatool.com/tag/entity-framework/
    • http://msdn.microsoft.com/en-us/magazine/ee236639.aspx
    • http://blogs.msdn.com/adonet/pages/feature-ctp-walkthrough-self-tracking-entities-for-the-entity-framework.aspx
    • http://blogs.msdn.com/adonet/pages/feature-ctp-walkthrough-poco-templates-for-the-entity-framework.aspx
    • http://blogs.msdn.com/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
    • http://blogs.msdn.com/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx
    • http://blogs.msdn.com/adonet/archive/2009/05/19/sneak-peek-using-code-generation-templates-with-the-entity--framework-4-0.aspx
    • http://blogger.forgottenskies.com/?p=518
    • http://msdn.microsoft.com/en-us/magazine/ee335715.aspx
    • http://blogs.msdn.com/efdesign/