I attended the PDC session by Shyam Pather and Chris Anderson at Microsft because I want to see learn about the way Microsoft looks at data. We’ve seen the evolution over the years. There is a wide array (some say dizzying array) of options for the developer to consume and publish data in its various forms.
Many times, data has an independent existence. In contrast, relationships are time dependent. For example, you may no longer be with a specific insurance company.
Usually you create a relational schema to see your chunks of data. But when it comes time to code you notice an employee is spread among a collection of tables. Relationships are important because they exist for data integrity, much like an order having many line items. Nice and easy from a query point of view. The ideal scenario is to have just an order object that automatically has all the line items in it already, or at least available by calling a method (you may want lazy loading, “loading on demand, not all the time).
Tables are often horizontally partitioned to support better performance and concurrency. This complicates the developers life because data is now even more fragmented.
Evolving ADO.NET Entity Framework in .NET 4 and Beyond
It is somewhat overwhelming to think about all the Microsoft technology surrounding data.
Cloud Storage is the latest in the Microsoft offerings with options for relational as wells Windows Azure Storage for access to secure anytime, anywhere data that is durable and scalable.
On Premise SQL Server
SQL Server Modeling Services
Note: Used to be called “Oslo” repository and the built-in domains.
I found this one to be the newest terminology. So I started to explore it. I essentially uncovered a ton of technologies being put under one umbrella:
It is about being able to build customizable frameworks for database applications
These are the base layers that we want to “abstract away” for our applications.
Figure Above: The lower level data stores for the Entity Framework
Why Entity Framework?
We will start with Visual Studio 2010 and begin modeling our blogging. We’ll create 3 entities and 2 relationships.
Let’s not waste anytime and write some code. I’m using Visual Studio 2010 here.
I will start with a WPF Application and add a database to it.
Choose “WPF Application” and provide:
Add a New Item (ADO.NET Entity Data Model)
Add “ADO.NET Entity Data Model.”
We will choose Empty model because we wish to build the database from the model, not the other way around.
An empty data model. This is the design surface where we can build our conceptual model. The design surface is ready for us to add entities.
You will need some simple skills. You will need to know how:
To add a "New Entity"
Built in pluralization that is pretty smart. If you say “Person,” it will pluralize to “People.”
Here is where we are so far:
It’s about relationships. From Blog to Post we need a 1-to-many relationship. A right-mouse click gets you “Add Association.”
How to setup the one-to-many relationship.
Blog has a one-to-many to Post.
Now it is time to setup a many-to-many.
Make sure you select:
Make sure to select many-to-many. It is from Post to Tag.
The promise of model driven development is that the database gets created based on the model. A simple right-mouse click gets you to “Generate Database from Model.”
Notice the model called BloggingModel.edmx.sql.
Here is the sql generated by Visual Studio 2010 Beta2.
Before we can run the script above, we need a database so what we have place to put the tables, relationships, indexes and so on.
Use Visual Studio 2010’s Server Explorer to “Create a New SQL Server Database.”
We will name ours BlogDB
Choose the target database for which the data will place all the tables, relationships, indices, etc.
Here is the script that results from the model we previously defined.
I pasted the script above into Microsoft SQL Server Management Studio.
We still need to run the sql script. I started Microsoft SQL Server Management Studio and hit “New Query”. The query uses “BlogDB” and then creates the needed tables and relationships.
To verify everything correctly, let’s get SQL Server Management Studio to generate a Database Diagram for us. Let’s add all the tables.
We’ve come full circle. We started with a conceptual entities in the ADO.NET Entity Framework and ended up with a physical representation in SQL Server.
Nice article...Followed the steps and understood the Model First approach
Looking forward to reading about other approaches, especially the Database first .