VIEWS: 18 PAGES: 24 POSTED ON: 12/13/2011
ADO.NET Entity Framework Deyan Varchev General Manager Avaxo Ltd. What Is It? The ADO.NET Entity Framework is part of Microsoft’s next Entity VS 2008 generation of .NET Framework technologies. It is intended to make LINQ .NET 3.5 it easier and more effective for object- oriented applications to work with data. THE PROBLEM BEING ADDRESSED Inherit differences between data expression in a relational database and the same data expressed in an object-oriented application. The Logical Data Model • Almost any business Tables application today has to speak to a relational database. Views • This involves the usual suspects of Stored Procedures tables with foreign keys, a smattering of views, and generally a Foreign Key gob of stored Relationships procedures. The Object-Oriented Domain Model • Applications Objects themselves are written in a Behavior completely different world. Properties • The same data that Inheritance lives in the relational database Complex Types is represented entirely differently in the application. The Result Logical Data The result of this Model “impedance mismatch” is that developers devote a Lots of lot of time and Custom Code energy writing code to translate between how the database Application likes to see data and Domain how the application likes to see data. Other Ways to Address The Same Problem • Hibernate (Java) • Enterprise Objects Framework (Mac OS) • NHibernate (.NET) • LINQ to SQL (Visual Studio 2008) • And many, many, more … The ADO.NET Entity Framework Logical Data Model • The ADO.NET Entity Framework seeks to remedy the problem Entity Data Model by providing a layer of abstraction Less Custom Code between the logical data model and the application domain. Application Domain Why the Entity Model? Closer to the application problem space Better suited for object oriented programming Supports Inheritance Supports complex types Relationships are more meaningful to the application THE “STUFF” IN ADO.NET ENTITY FRAMEWORK The tools and technology that developers will interact with when using the ADO.NET Entity Framework Entity Data Model • A gob of XML that defines • Logical Data Tables, Views, Foreign Keys • Entity Objects that Map to the Logical Data • The Mapping Between the Two Entity Data Model Designer • A Visual Studio Designer that protects developers from the XML that is the EDM ObjectContext • A code-generated data context created from the Entity Data Model • Responsible for managing communication between the conceptual data model and the logical data model Entities • Code-generated class definitions for objects defined in the EDM. GETTING THE DATA OUT How do we get data out of the fancy Entity Data Model? eSQL (Entity SQL) A brand new SQL language to learn Leverages the rich, object-oriented Entity Data Model Inheritance Collections Complex Types Literal Strings – No Compiler Checking Questionable value in embedded SQL in code Extensions Methods and String Predicates • Queries the object model created against the EDM • Still string-based. No compiler checking • An ugly mix of code and eSQL statements LINQ to Entities • Full compiler checking. No wondering if the query is valid. • A fun new SQL-Like syntax • More OO-ish WHAT CAN YOU DO? The power of the Entity Data Model contrasted to a logical data model of tables and stored procedures. Combine Multiple Logical Tables into One Entity Database Tables Entity Data Model Implement Inheritance Database Tables Entity Data Model Other Fun Stuff • Implement Complex Types (e.g. Address) • Consume Conceptual Model with Reporting Services and other BI Tools • Create an EDM that talks to stored procedures • Use transactions, manage concurrency, cache execution plans Manipulate Data By Manipulating Objects Database Result Desired EDM Object Manipulation INSERT ROW Create new object Add object to EDM Context Update Context DELETE ROW Get instance of object from EDM Context Ask Context to remove the object Update Context UPDATE ROW Get instance of object from EDM Context Update object Update Context Lecture Topic Questions?
Pages to are hidden for
"Deyan Varchev ITBoxing ADO NET Entity Framework"Please download to view full document