Vince Plaza's Blog

...Microsoft .NET programming ideas and samples

Create an Adventure Works Entity Framework Model

Written by Vince Plaza on August 11th, 2009

It is easy to create a simple Entity Framework model using the Adventure Works SQL Server database. I will use a WPF Model View project as my container. To start, create a new WPF Model View Application as described in this posting:

Right click on the Model folder in the Solution Explorer, select Add and then select New Item from the context menu.

(click to enlarge)

(click to enlarge)

Select the ADO.Net Entity Data Model template and name it AdventureWorks.edmx.

(click to enlarge)

(click to enlarge)


On the next dialog, create a connection to the AdventureWorksdatabase you plan on using, or select sn existing oneĀ usingĀ the drop down. Use the default recommendation for naming and storing the connection string in the App.config file. In my case, the connection name is prefixed with Milo because that is the name of my local machine.

(click to enlarge)

(click to enlarge)

On the next dialog, select the option to create a model from a database.

(click to enlarge)

(click to enlarge)

Then select the tables you want to include. I selected three tables from the Sales schema for this example.

EF_ChooseDatabaseObjextsDialog_AWSalesTables

That is all there is to it. The model should open up in the GUI designer.

(click to enlarge)

(click to enlarge)

In the next post I will show a couple of property changes I make to support future samples that use the model.

You must be logged in to post a comment.