Introducing the Entity Framework

1,168 views

Published on

Learn about how object-relational mapping works to provide data access and understand what the Entity Framework is and how it can provide robust data access services to applications.

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

No Downloads
Views
Total views
1,168
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Building the Entity Data Model and Objects, Exploring the New Entity Object Project\n
  • DEMO: Try It Out!\n
  • DEMO: Try It Out!\n
  • DEMO: Try It Out!\n
  • DEMO: Try It Out!\n
  • DEMO: Try It Out!\n
  • DEMO: Try It Out!\n
  • DEMO: Try It Out!\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • DEMO: rest of section\n
  • Introducing the Entity Framework

    1. 1. Introducing the EntityFramework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    2. 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    3. 3. Objectives• Learn about how object-relational mapping works to provide data access Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    4. 4. Objectives• Learn about how object-relational mapping works to provide data access• Understand what the Entity Framework is and how it can provide robust data access services to applications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    5. 5. Objectives• Learn about how object-relational mapping works to provide data access• Understand what the Entity Framework is and how it can provide robust data access services to applications• See how to build a database-first Entity Data Model using Visual Studio Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    6. 6. Objectives• Learn about how object-relational mapping works to provide data access• Understand what the Entity Framework is and how it can provide robust data access services to applications• See how to build a database-first Entity Data Model using Visual Studio• Explore the various Entity Framework APIs and tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    7. 7. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    8. 8. Agenda• Object-Relational Mapping (ORM) and Data Access Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    9. 9. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    10. 10. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    11. 11. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework• Entity Framework APIs and Tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    12. 12. Object-Relational Mapping (ORM) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    13. 13. Object-Relational Mapping (ORM)• Just about all applications make use of data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    14. 14. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    15. 15. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    16. 16. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems  Too close to the metal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    17. 17. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems  Too close to the metal  Use generic data objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    18. 18. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems  Too close to the metal  Use generic data objects• Data access code is usually a lot of code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    19. 19. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems  Too close to the metal  Use generic data objects• Data access code is usually a lot of code• Differences between objects and database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    20. 20. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems  Too close to the metal  Use generic data objects• Data access code is usually a lot of code• Differences between objects and database• Entity Framework bridges the gap Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    21. 21. Object-Relational Mapping (ORM)• Just about all applications make use of data• Microsoft has a long history of providing data access technologies• But they have problems  Too close to the metal  Use generic data objects• Data access code is usually a lot of code• Differences between objects and database• Entity Framework bridges the gap• Terminology: data store and database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    22. 22. Object/Relational Differences Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    23. 23. Object/Relational Differences• Inherent problems application has to overcome Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    24. 24. Object/Relational Differences• Inherent problems application has to overcome  Needs lots of code somewhere Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    25. 25. Object/Relational Differences• Inherent problems application has to overcome  Needs lots of code somewhere  Big impact on application design, effort, and performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    26. 26. Object/Relational Differences• Inherent problems application has to overcome  Needs lots of code somewhere  Big impact on application design, effort, and performance• Will discuss in the context of a relational database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    27. 27. Data Type Differences Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    28. 28. Data Type Differences• Many kinds of data types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    29. 29. Data Type Differences• Many kinds of data types• SQL Server 2008 R2 data types: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    30. 30. Data Type Differences• Many kinds of data types• SQL Server 2008 R2 data types: bigint binary bit char CLR date datetime datetime2 datetimeoffset decimal float hierarchyid image int money nchar ntext numeric nvarchar real rowversion smalldatetime smallint smallmoney sql_variant table text time timestamp tinyint varbinary varchar uniqueidentifier Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    31. 31. Data Type Differences• Many kinds of data types• SQL Server 2008 R2 data types: bigint binary bit char CLR date datetime datetime2 datetimeoffset decimal float hierarchyid image int money nchar ntext numeric nvarchar real rowversion smalldatetime smallint smallmoney sql_variant table text time timestamp tinyint varbinary varchar uniqueidentifier Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    32. 32. Data Type Differences• Many kinds of data types• SQL Server 2008 R2 data types: bigint binary bit char CLR date datetime datetime2 datetimeoffset decimal float hierarchyid image int money nchar ntext numeric nvarchar real rowversion smalldatetime smallint smallmoney sql_variant table text time timestamp tinyint varbinary varchar uniqueidentifier Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    33. 33. Data Type Differences• Many kinds of data types• SQL Server 2008 R2 data types: bigint binary bit char CLR date datetime datetime2 datetimeoffset decimal float hierarchyid image int money nchar ntext numeric nvarchar real rowversion smalldatetime smallint smallmoney sql_variant table text time timestamp tinyint varbinary varchar uniqueidentifier Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    34. 34. Data Type Differences• Many kinds of data types• SQL Server 2008 R2 data types: bigint binary bit char CLR date datetime datetime2 datetimeoffset decimal float hierarchyid image int money nchar ntext numeric nvarchar real rowversion smalldatetime smallint smallmoney sql_variant table text time timestamp tinyint varbinary varchar uniqueidentifier• Some have direct equivalents in .NET• Database types often have constraints• Binary data in the database can be anything• Dates and times are another issue Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    35. 35. Relationship Difference Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    36. 36. Relationship Difference• Databases use foreign key constraints Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    37. 37. Relationship Difference• Databases use foreign key constraints• .NET objects use object references Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    38. 38. Relationship Difference• Databases use foreign key constraints• .NET objects use object references• SalesOrderHeader and SalesOrderDetail tables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    39. 39. Relationship Difference• Databases use foreign key constraints• .NET objects use object references• SalesOrderHeader and SalesOrderDetail tables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    40. 40. Relationship Difference• Databases use foreign key constraints• .NET objects use object references• SalesOrderHeader and SalesOrderDetail tables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    41. 41. Relationship Difference Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    42. 42. Relationship Difference• Many-to-Many relationships Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    43. 43. Relationship Difference• Many-to-Many relationships• In AdventureWorks, customers and addresses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    44. 44. Relationship Difference• Many-to-Many relationships• In AdventureWorks, customers and addresses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    45. 45. Relationship Difference• Many-to-Many relationships• In AdventureWorks, customers and addresses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    46. 46. Relationship Difference• Many-to-Many relationships• In AdventureWorks, customers and addresses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    47. 47. Relationship Difference• Many-to-Many relationships• In AdventureWorks, customers and addresses• Not the default objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    48. 48. Inheritance Difference Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    49. 49. Inheritance Difference• .NET supports object inheritance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    50. 50. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    51. 51. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    52. 52. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    53. 53. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects• Relational databases don’t support inheritance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    54. 54. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects• Relational databases don’t support inheritance• Some ways to accomplish it Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    55. 55. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects• Relational databases don’t support inheritance• Some ways to accomplish it  Table per type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    56. 56. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects• Relational databases don’t support inheritance• Some ways to accomplish it  Table per type  Table per concrete type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    57. 57. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects• Relational databases don’t support inheritance• Some ways to accomplish it  Table per type  Table per concrete type  Table per hierarchy Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    58. 58. Inheritance Difference• .NET supports object inheritance  No support for multiple inheritance• Inheritance makes code simpler, maintainable, easier to debug  Model hierarchies of objects• Relational databases don’t support inheritance• Some ways to accomplish it  Table per type  Table per concrete type  Table per hierarchy• Have to manage special constraints Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    59. 59. Identity/Equality Difference Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    60. 60. Identity/Equality Difference• How do you tell two things are the same? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    61. 61. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    62. 62. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    63. 63. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint  Can use either natural or surrogate keys Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    64. 64. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint  Can use either natural or surrogate keys• Objects in object-oriented application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    65. 65. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint  Can use either natural or surrogate keys• Objects in object-oriented application  Two objects with the same data are not equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    66. 66. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint  Can use either natural or surrogate keys• Objects in object-oriented application  Two objects with the same data are not equal  Two variables, each with reference to different objects, are not equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    67. 67. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint  Can use either natural or surrogate keys• Objects in object-oriented application  Two objects with the same data are not equal  Two variables, each with reference to different objects, are not equal  Two variables with reference to same object are equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    68. 68. Identity/Equality Difference• How do you tell two things are the same?• Database: identity of a row is the primary key  Enforced by a primary key constraint  Can use either natural or surrogate keys• Objects in object-oriented application  Two objects with the same data are not equal  Two variables, each with reference to different objects, are not equal  Two variables with reference to same object are equal  Can make a custom definition Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    69. 69. Handling the Differences Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    70. 70. Handling the Differences• Can be an lot of work to handle object/relational differences Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    71. 71. Handling the Differences• Can be an lot of work to handle object/relational differences  But at least they are well understood Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    72. 72. Handling the Differences• Can be an lot of work to handle object/relational differences  But at least they are well understood  Doesn’t mean it’s easy Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    73. 73. Handling the Differences• Can be an lot of work to handle object/relational differences  But at least they are well understood  Doesn’t mean it’s easy• Write the code yourself, or use a framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    74. 74. Object-Relational Mapping (ORM) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    75. 75. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    76. 76. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types• Most ORM tools rely on metadata about database and objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    77. 77. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types• Most ORM tools rely on metadata about database and objects• Clean separation of concerns Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    78. 78. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types• Most ORM tools rely on metadata about database and objects• Clean separation of concerns• Key feature is mapping Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    79. 79. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types• Most ORM tools rely on metadata about database and objects• Clean separation of concerns• Key feature is mapping  Expresses how an object is related to a table Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    80. 80. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types• Most ORM tools rely on metadata about database and objects• Clean separation of concerns• Key feature is mapping  Expresses how an object is related to a table  ORM uses to manage conversion process Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    81. 81. Object-Relational Mapping (ORM)• Programming technique for conversion of incompatible types• Most ORM tools rely on metadata about database and objects• Clean separation of concerns• Key feature is mapping  Expresses how an object is related to a table  ORM uses to manage conversion process• ORM manages application’s interactions with database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    82. 82. Benefits to using an ORM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    83. 83. Benefits to using an ORM• Productivity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    84. 84. Benefits to using an ORM• Productivity• Better application design Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    85. 85. Benefits to using an ORM• Productivity• Better application design• Code reuse Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    86. 86. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    87. 87. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability• Potential downside: performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    88. 88. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability• Potential downside: performance  More complex code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    89. 89. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability• Potential downside: performance  More complex code  Means slower performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    90. 90. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability• Potential downside: performance  More complex code  Means slower performance  But ORM code is likely to be well tuned Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    91. 91. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability• Potential downside: performance  More complex code  Means slower performance  But ORM code is likely to be well tuned  Data access time may be minimal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    92. 92. Benefits to using an ORM• Productivity• Better application design• Code reuse• Application maintainability• Potential downside: performance  More complex code  Means slower performance  But ORM code is likely to be well tuned  Data access time may be minimal• Lots of ORMs available for .NET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    93. 93. Generic Data Objects vs. Entity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    94. 94. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    95. 95. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    96. 96. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    97. 97. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection  SqlDataAdapter and OleDbAdapter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    98. 98. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection  SqlDataAdapter and OleDbAdapter  DataSet Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    99. 99. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection  SqlDataAdapter and OleDbAdapter  DataSet  DataTable Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    100. 100. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection  SqlDataAdapter and OleDbAdapter  DataSet  DataTable  SqlDataReader and OleDbDataReader Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    101. 101. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection  SqlDataAdapter and OleDbAdapter  DataSet  DataTable  SqlDataReader and OleDbDataReader• Provide a means for accessing data in database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    102. 102. Generic Data Objects vs. Entity• ADO.NET has long had generic data objects• Most common:  SqlConnection and OleDbConnection  SqlDataAdapter and OleDbAdapter  DataSet  DataTable  SqlDataReader and OleDbDataReader• Provide a means for accessing data in database  DataSet and DataTable contain rows and columns Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    103. 103. Generic Data Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    104. 104. Generic Data Objects• Problems with Generic Data Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    105. 105. Generic Data Objects• Problems with Generic Data Objects  Strong coupling between application and database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    106. 106. Generic Data Objects• Problems with Generic Data Objects  Strong coupling between application and database  Loose typing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    107. 107. Generic Data Objects• Problems with Generic Data Objects  Strong coupling between application and database  Loose typing  Object interactions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    108. 108. Generic Data Objects• Problems with Generic Data Objects  Strong coupling between application and database  Loose typing  Object interactions• Problems persist despite long use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    109. 109. Generic Data Objects• Problems with Generic Data Objects  Strong coupling between application and database  Loose typing  Object interactions• Problems persist despite long use  Every application has to deal with them Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    110. 110. Generic Data Objects• Problems with Generic Data Objects  Strong coupling between application and database  Loose typing  Object interactions• Problems persist despite long use  Every application has to deal with them  But it’s been the best we’ve had, other than custom objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    111. 111. Entity Data Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    112. 112. Entity Data Objects• Big improvement over what came before Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    113. 113. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    114. 114. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail  Navigation properties to access related data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    115. 115. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail  Navigation properties to access related data  Fit into object-oriented application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    116. 116. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail  Navigation properties to access related data  Fit into object-oriented application• Object interfaces can mirror tables and fields Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    117. 117. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail  Navigation properties to access related data  Fit into object-oriented application• Object interfaces can mirror tables and fields  Or be completely different Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    118. 118. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail  Navigation properties to access related data  Fit into object-oriented application• Object interfaces can mirror tables and fields  Or be completely different  Or something in between Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    119. 119. Entity Data Objects• Big improvement over what came before  Instead of using a generic DataSet, use Customer, Order, and OrderDetail  Navigation properties to access related data  Fit into object-oriented application• Object interfaces can mirror tables and fields  Or be completely different  Or something in between• Need a way to map objects to database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    120. 120. Benefits of Entity Data Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    121. 121. Benefits of Entity Data Objects• Strong typing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    122. 122. Benefits of Entity Data Objects• Strong typing• Compile-time checking Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    123. 123. Benefits of Entity Data Objects• Strong typing• Compile-time checking• Persistence ignorance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    124. 124. Benefits of Entity Data Objects• Strong typing• Compile-time checking• Persistence ignorance• Productivity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    125. 125. Data Programming Against a Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    126. 126. Data Programming Against a Model• Will have to change how you think about data in an application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    127. 127. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    128. 128. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database  Instead working with objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    129. 129. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database  Instead working with objects  Very different paradigms Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    130. 130. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database  Instead working with objects  Very different paradigms• The model is not the database! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    131. 131. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database  Instead working with objects  Very different paradigms• The model is not the database!• Generic data objects require lots of code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    132. 132. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database  Instead working with objects  Very different paradigms• The model is not the database!• Generic data objects require lots of code• Entity data objects mean querying a schema that reflects business model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    133. 133. Data Programming Against a Model• Will have to change how you think about data in an application  No longer interacting directly with the database  Instead working with objects  Very different paradigms• The model is not the database!• Generic data objects require lots of code• Entity data objects mean querying a schema that reflects business model• ORM eliminates context shift in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    134. 134. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    135. 135. Agenda• Object-Relational Mapping (ORM) and Data Access Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    136. 136. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    137. 137. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    138. 138. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework• Entity Framework APIs and Tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    139. 139. The Entity Framework and DataModel Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    140. 140. The Entity Framework and DataModel• Complete ORM for .NET applications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    141. 141. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    142. 142. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    143. 143. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    144. 144. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction• Version 4.1 is a mature product Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    145. 145. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction• Version 4.1 is a mature product  Substantial commitment and innovation Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    146. 146. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction• Version 4.1 is a mature product  Substantial commitment and innovation• Do we need a new data access technology? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    147. 147. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction• Version 4.1 is a mature product  Substantial commitment and innovation• Do we need a new data access technology?  Older technologies have run their course Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    148. 148. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction• Version 4.1 is a mature product  Substantial commitment and innovation• Do we need a new data access technology?  Older technologies have run their course  Modern applications have to focus on domain model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    149. 149. The Entity Framework and DataModel• Complete ORM for .NET applications• Microsoft’s new core data access technology  Big commitment from the company• Initial release didn’t gain much traction• Version 4.1 is a mature product  Substantial commitment and innovation• Do we need a new data access technology?  Older technologies have run their course  Modern applications have to focus on domain model• Version numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    150. 150. Entity Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    151. 151. Entity Data Model• Integral part of Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    152. 152. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    153. 153. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema• Describes structure of entity data objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    154. 154. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema• Describes structure of entity data objects• Take the database schema and reshape it into objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    155. 155. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema• Describes structure of entity data objects• Take the database schema and reshape it into objects• Defined by three chunks of XML in a single .edmx file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    156. 156. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema• Describes structure of entity data objects• Take the database schema and reshape it into objects• Defined by three chunks of XML in a single .edmx file  Conceptual model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    157. 157. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema• Describes structure of entity data objects• Take the database schema and reshape it into objects• Defined by three chunks of XML in a single .edmx file  Conceptual model  Storage model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    158. 158. Entity Data Model• Integral part of Entity Framework• Client-side model different from database schema• Describes structure of entity data objects• Take the database schema and reshape it into objects• Defined by three chunks of XML in a single .edmx file  Conceptual model  Storage model  Mapping Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    159. 159. LINQ to SQL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    160. 160. LINQ to SQL• Similar to Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    161. 161. LINQ to SQL• Similar to Entity Framework  Both use LINQ to query a database using a data model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    162. 162. LINQ to SQL• Similar to Entity Framework  Both use LINQ to query a database using a data model• Developed independently at Microsoft Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    163. 163. LINQ to SQL• Similar to Entity Framework  Both use LINQ to query a database using a data model• Developed independently at Microsoft  LINQ to SQL grew out of LINQ team Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    164. 164. LINQ to SQL• Similar to Entity Framework  Both use LINQ to query a database using a data model• Developed independently at Microsoft  LINQ to SQL grew out of LINQ team  Entity Framework grew out of Data Programmability team Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    165. 165. LINQ to SQL• Similar to Entity Framework  Both use LINQ to query a database using a data model• Developed independently at Microsoft  LINQ to SQL grew out of LINQ team  Entity Framework grew out of Data Programmability team• Soon Microsoft had two new data access technologies Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    166. 166. LINQ to SQL• Similar to Entity Framework  Both use LINQ to query a database using a data model• Developed independently at Microsoft  LINQ to SQL grew out of LINQ team  Entity Framework grew out of Data Programmability team• Soon Microsoft had two new data access technologies• LINQ to SQL moved, and lost out to Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    167. 167. Why Use Entity Framework? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    168. 168. Why Use Entity Framework?• Part of the .NET Framework and integrated into Visual Studio Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    169. 169. Why Use Entity Framework?• Part of the .NET Framework and integrated into Visual Studio• Uses LINQ as the primary query language Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    170. 170. Why Use Entity Framework?• Part of the .NET Framework and integrated into Visual Studio• Uses LINQ as the primary query language• Independent of the data source Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    171. 171. Why Use Entity Framework?• Part of the .NET Framework and integrated into Visual Studio• Uses LINQ as the primary query language• Independent of the data source• Microsoft’s primary data access strategy Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    172. 172. When Should You Not Use EntityFramework or an ORM? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    173. 173. When Should You Not Use EntityFramework or an ORM?• Entity Framework is not a panacea Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    174. 174. When Should You Not Use EntityFramework or an ORM?• Entity Framework is not a panacea  Not an instant data access panacea Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    175. 175. When Should You Not Use EntityFramework or an ORM?• Entity Framework is not a panacea  Not an instant data access panacea  Isn’t appropriate for every kind of application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    176. 176. When Should You Not Use EntityFramework or an ORM?• Entity Framework is not a panacea  Not an instant data access panacea  Isn’t appropriate for every kind of application  Doesn’t do bulk inserts Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    177. 177. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    178. 178. Agenda• Object-Relational Mapping (ORM) and Data Access Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    179. 179. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    180. 180. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    181. 181. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework• Entity Framework APIs and Tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    182. 182. Building a Simple Application usingEntity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    183. 183. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    184. 184. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    185. 185. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT  Ten tables with data about customers, products, and orders Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    186. 186. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT  Ten tables with data about customers, products, and orders  Complex enough to exercise Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    187. 187. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT  Ten tables with data about customers, products, and orders  Complex enough to exercise Entity Framework• Will build sample as a class library Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    188. 188. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT  Ten tables with data about customers, products, and orders  Complex enough to exercise Entity Framework• Will build sample as a class library  Easy to reuse in multiple applications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    189. 189. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT  Ten tables with data about customers, products, and orders  Complex enough to exercise Entity Framework• Will build sample as a class library  Easy to reuse in multiple applications  Not absolutely necessary Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    190. 190. Building a Simple Application usingEntity Framework• Compelling reason to use Entity Framework is its integration with Visual Studio• Sample is based on AdventureWorksLT  Ten tables with data about customers, products, and orders  Complex enough to exercise Entity Framework• Will build sample as a class library  Easy to reuse in multiple applications  Not absolutely necessary• Mostly create simple console applications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    191. 191. Using the Entity Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    192. 192. Using the Entity Objects• Time to use the entity data objects in an application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    193. 193. Using the Entity Objects• Time to use the entity data objects in an application• Simple console application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    194. 194. Using the Entity Objects• Time to use the entity data objects in an application• Simple console application• Need to do three things to use the class library Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    195. 195. Using the Entity Objects• Time to use the entity data objects in an application• Simple console application• Need to do three things to use the class library  Add a reference to the class library Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    196. 196. Using the Entity Objects• Time to use the entity data objects in an application• Simple console application• Need to do three things to use the class library  Add a reference to the class library  Add a reference to System.Data.Entity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    197. 197. Using the Entity Objects• Time to use the entity data objects in an application• Simple console application• Need to do three things to use the class library  Add a reference to the class library  Add a reference to System.Data.Entity  Add the Entity Framework connection string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    198. 198. Using the Entity Objects• Time to use the entity data objects in an application• Simple console application• Need to do three things to use the class library  Add a reference to the class library  Add a reference to System.Data.Entity  Add the Entity Framework connection string• And, of course, write some code! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    199. 199. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    200. 200. Agenda• Object-Relational Mapping (ORM) and Data Access Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    201. 201. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    202. 202. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    203. 203. Agenda• Object-Relational Mapping (ORM) and Data Access• The Entity Framework and Data Model• Building a Simple Application using Entity Framework• Entity Framework APIs and Tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    204. 204. Entity Framework APIs and Tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    205. 205. Entity Framework APIs and Tools• Entity Framework is a complex set of APIs and design tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    206. 206. Entity Framework APIs and Tools• Entity Framework is a complex set of APIs and design tools• Need a basic understanding of what each of the Entity Framework components do Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    207. 207. Entity Framework APIs and Tools• Entity Framework is a complex set of APIs and design tools• Need a basic understanding of what each of the Entity Framework components do  Road to deep understanding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    208. 208. Architecture Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    209. 209. ApplicationArchitecture Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    210. 210. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    211. 211. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Object Services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    212. 212. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Object Services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    213. 213. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Object Services Command Tree Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    214. 214. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Object Services Command Tree EntityClient Data Provider Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    215. 215. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Object Services Command Entity Tree Data Reader EntityClient Data Provider Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    216. 216. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Entity SQL Query Object Services Command Entity Tree Data Reader EntityClient Data Provider Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    217. 217. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Entity SQL Query Object Services Command Entity Tree Data Reader EntityClient Data Provider Command Tree Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    218. 218. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Entity SQL Query Object Services Command Entity Tree Data Reader EntityClient Data Provider Command Tree ADO.NET Data Providers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    219. 219. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Entity SQL Query Object Services Command Entity Tree Data Reader EntityClient Data Provider Command Tree DB Data Reader ADO.NET Data Providers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    220. 220. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Results Entity SQL Query Object Services Command Entity Tree Data Reader EntityClient Data Provider Command Tree DB Data Reader ADO.NET Data Providers Data Store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    221. 221. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Entity Data Results Entity Model SQL Query Object Services Command Entity Tree Data Reader EntityClient Data Provider Command Tree DB Data Reader ADO.NET Data Providers Data Store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    222. 222. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Entity Data Results Entity Model SQL Query Object Services Conceptual Model Command Entity Tree Data Reader EntityClient Data Provider Command Tree DB Data Reader ADO.NET Data Providers Data Store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    223. 223. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Entity Data Results Entity Model SQL Query Object Services Conceptual Model Command Entity Tree Data Reader EntityClient Data Provider Command Tree DB Data Storage Reader Model ADO.NET Data Providers Data Store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    224. 224. ApplicationArchitecture Entity SQL LINQ to Entities Query Query Entity Data Results Entity Model SQL Query Object Services Conceptual Model Command Entity Tree Data Reader Mapping EntityClient Data Provider Command Tree DB Data Storage Reader Model ADO.NET Data Providers Data Store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    225. 225. Entity Data Model Designer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    226. 226. Entity Data Model Designer• Part of Visual Studio Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    227. 227. Entity Data Model Designer• Part of Visual Studio• Lets you work with model graphically rather than as raw XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    228. 228. Entity Data Model Designer• Part of Visual Studio• Lets you work with model graphically rather than as raw XML• First saw as part of the AdventureWorksLibrary project Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    229. 229. Entity Data Model Designer• Part of Visual Studio• Lets you work with model graphically rather than as raw XML• First saw as part of the AdventureWorksLibrary project• Doesn’t support all Entity Data Model features Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    230. 230. Entity Data Model Designer• Part of Visual Studio• Lets you work with model graphically rather than as raw XML• First saw as part of the AdventureWorksLibrary project• Doesn’t support all Entity Data Model features• Lets you map tables, views, stored procedures and functions to entities Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    231. 231. Entity Data Model Designer• Part of Visual Studio• Lets you work with model graphically rather than as raw XML• First saw as part of the AdventureWorksLibrary project• Doesn’t support all Entity Data Model features• Lets you map tables, views, stored procedures and functions to entities  Can update the model from the underlying database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    232. 232. Design Methodologies Using theDesigner Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    233. 233. Design Methodologies Using theDesigner• Two broad ways to build a data application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    234. 234. Design Methodologies Using theDesigner• Two broad ways to build a data application  Top-down design Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    235. 235. Design Methodologies Using theDesigner• Two broad ways to build a data application  Top-down design  Bottom-up design Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    236. 236. Design Methodologies Using theDesigner• Two broad ways to build a data application  Top-down design  Bottom-up design• Neither is necessarily better than the other Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    237. 237. Design Methodologies Using theDesigner• Two broad ways to build a data application  Top-down design  Bottom-up design• Neither is necessarily better than the other• Entity Framework supports both Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    238. 238. Design Methodologies Using theDesigner• Two broad ways to build a data application  Top-down design  Bottom-up design• Neither is necessarily better than the other• Entity Framework supports both• Provides three ways to build an application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

    ×