If you haven’t already, read the article this example is based on or start at the beginning of this example.
In Visual Studio 2010, create a blank solution named Customer Success Stories:
Write click on the solution and Add | New Project:
Create a Class Library project named CSSModel:
Delete the class file and then Add | New Item:
Choose ADO.NET Entity Data Model and name it CSSModel:
Choose Empty Model and Finish:
Drag a couple of entities from the toolbox onto the design surface. Rename one Company and give it Name and Country properties. Name the other Story and give it Headline and Detail properties:
For this project, DON’T use the toolbar to add the association. Instead, right-click on Company and Add | Association (make sure “Add foreign key …” is checked):
Your model should look like this:
Right-click on the design surface to Generate Database from Model:
If you haven’t connected to your SQL Azure database yet, you’ll need to create a new connection:
Enter your fully qualified DNS name (found on the right side of the database page in the Windows Azure portal). Then choose SQL Server Authentication with the user name and password you created. Click the Test Connection button to verify that your connection is working, and then you can select the database name:
On the next screen, click “Yes …” to include sensitive data in the connection string (you have to put it somewhere – this will put it in a .config file, which is a good place):
Click Finish to generate the DDL and open CSSModel.edmx.sql. On the SQL toolbar, click the Connect button:
Once again, enter your fully qualified DNS name for your database, along with your SQL Server Authentication credentials (the first time, it’s remembered in App.Config – this time, it’s remembered by Visual Studio itself):
If you try to execute the SQL at this point, it will fail, because the “Master” database is selected and SQL Azure does not understand the “Use” statement at this time. So select CSSDB from the database dropdown and then click execute:
Now you have a SQL Azure database. You can manipulate it by clicking Manage on the database toolbar in the Windows Azure account portal: