Windows Azure - SQL Azure - Using ADO.NET Entity Framework - Creating DataModel

Another good remarkable point regarding SQL Azure is the reuse of our existing skills with ADO.NET Entity Framework. As the SQL Azure connectivity using ADO.NET is possible, it opens the door for Entity Framework as well.

Abut ADO.NET Entity Framework

ADO.NET Entity Framework is an ORM (Object Relational Mapping) framework from Microsoft. It provides the flexibilities like tables to entities, relational mapping to properties, Data operations to encapsulated methods etc.

ADO.NET Entity Framework

Surely it gives the advantages of:

  • Wrapping of database in Object Oriented Manner
  • More Manageability
  • More Flexibility
  • Less Development Time

But everything comes at the cost of learning. You can find more information here.

Creating Schema

Create a new Windows Azure project and add a new web role into it. After that right click on the project and use Add > New Item. In the appearing dialog choose the Data item from the left pane and ADO.NET Entity Data Model from the right pane.

ADO.NET Entity data model

Enter the names as MyModel as shown above. Click the Add button to continue to see the following screen.

 Entity data model

In the above dialog choose the default option (Generate from database) and click the Next button to continue.

ADO.NET Entity Framework with sql azure

In the appearing dialog choose your existing connection from the drop down list and click Next to continue..

windows azure ADO.NET Entity Framework

You will be prompted with the login dialog above. Enter your user name and password to continue. (The Save my password option saves the password to the connection string in config)

In the next dialog, select the tables as shown below and click Finish button.

ADO.NET Entity

This will generate the entity data model files in your project. You can see that the Employee table from previous example is populated in the tables and it generates the Employee class as shown below.

Entity data model

Note: If your database does not contain the above table, you may need to create the table and repeat the operations.


In this article we have explored the scope of using ADO.NET Entity Framework on SQL Azure. The possibilities give us more flexibility, control and reuse of our existing ORM skills. The source code attached contains the Entity Data Model code. You need to change the database name, user name and password in the configuration file.