Resource Page DescriptionMicrosoft's Entity Data Model allows us to define an application-oriented view of our data consistent with how we reason about that data. For object oriented modeling, the ability to quickly map inheritance hierarchies to RDBMS is the most important benefit of using Entity Framework, with its visual designer.
We will have working examples of TPT (Table per type), and TPH (Table per hierarchy) implemented in Visual Studio 2008 SP1.
We will explore a very interesting example where an entire application is modeled visually using the EF designer. A set of classes (with inheritance) are automatically generated by the EF designer without having to write down any single line of code in C#, VB, or even XML. For this particular example, no knowledge of XML, or SQL is needed -- just clicking, selecting, and specifying the object properties corresponding to table columns (in a friendly UI) is good enough.
Introduction
Enterprise applications require division of responsibilities between different teams of IT professionals, developers, and data base administrators. Since the data is shared by many applications, the programmers seldom have the choice of asking DBAs to adjust database schema just because it would be most convenient for them to program that way; instead, they are supposed to write down the data access layer on top of an existing schema. The database schemas are almost always optimized for RDBMS performance/usage patterns, and hence do not always correspond to application objects. For example, class inheritance is not very easy to implement directly in databases, and hence it remains a challenge for the developers to accurately model them in their code. Similarly, a heavily normalized set of tables require lot of joins in their SQL before they can extract a useful report. It also pretty challenging to create a database schema, which would satisfy every conceivable application need; and would still be the highest performer, storage efficient, and flexible.
Developers need to have an intimate knowledge of not only how to write SQL, but also how so many tables are joined in a particular schema. They embed those statement strings in application programs that are hard-coded to a specific table structure at a given time. This makes their code brittle, as any change in application or database schema requires a corresponding update of those SQL strings, and hence constant re-compilation/testing/deployment of newly built binaries. Moreover, those SQL strings are opaque to compiler, and hence they always compile, while still breaking at runtime. Most of the time, it is pretty hard to accurately estimate how many programs would need an update by database schema optimization, as applications don’t often have an explicit data model declared at one place.
Videos for beginners
If you are a beginner to Entity Framework, I recommend this wonderful video:
http://msdn.microsoft.com/en-us/data/cc765425.aspxThere are also lot of useful videos on this topic at:
http://msdn.microsoft.com/en-us/data/cc300162.aspx
Documentation
Besides "
Documentation.doc" file in "Downloads" tab, please see the blog
http://fhalim.spaces.live.com/.
It was also used at CodeApalooza
http://www.codeapalooza.com/agenda.htm Data Layer session.
An earlier version is also available at:
http://www.codeproject.com/KB/architecture/LinqEntityFramework.aspx