{"id":1479,"date":"2012-04-26T00:00:00","date_gmt":"2012-04-26T00:00:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/how-to-set-up-a-database-driven-azure-site\/"},"modified":"2021-02-23T19:43:28","modified_gmt":"2021-02-23T19:43:28","slug":"how-to-set-up-a-database-driven-azure-site","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/uncategorized\/how-to-set-up-a-database-driven-azure-site\/","title":{"rendered":"How to set up a database-driven Azure site"},"content":{"rendered":"<div class=\"article-content\">\n<p>This article is really a review of the alternative ways to get started with setting up a database-driven Azure site. I&#8217;ll start by using SQL Azure Management Portal and SQL Server Management Studio. Then, I&#8217;ll use Visual Studio to create a SQL Azure database (Web edition, 1 GB). I&#8217;m going to add a single Customer table and I&#8217;m going to see if I can deploy a LightSwitch application using that database.<\/p>\n<h2>SQL Azure is NOT SQL Server<\/h2>\n<p>Yes, SQL Azure is NOT SQL Server. I&#8217;ve wanted to say that for weeks &#8211; now I&#8217;ve said it. I keep hearing from so many sources that SQL Azure is SQL Server in the Cloud and to a degree that is correct. SQL Azure <em>is<\/em> a relational database system with many similarities to SQL Server; after all, both are Microsoft products. Beyond that many things from the developer&#8217;s perspective take a divergent direction.<\/p>\n<p>Taking a broad look, it takes planning to create any application that uses a database to store information. Let&#8217;s assume that you have elected to use SQL Azure as your database system. Now you need to do two things to get started;<\/p>\n<p>A. Name and generate a database.<\/p>\n<p>B. Build tables for that database.<\/p>\n<p>For me, the choice with SQL Server has always been simple; use SQL Server Management Studio. This is largely because it has some useful built-in wizards. I&#8217;ve never been put in the position of having to use scripts to do these things but with SQL Azure and SSMS you are stuck with scripts.<\/p>\n<p>There is a way of avoiding the use of scripts, however, since SQL Azure offers a management tool of its own much like SSMS, and Visual Studio 11 has some terrific tools available. We&#8217;re therefore&#160;going to explore these options for creating a database and the table using the tools that are currently available. I think you&#8217;ll be pleasantly surprised (or at least surprised) so sit back and enjoy the ride.<\/p>\n<h2>Creating a database<\/h2>\n<p>Many things about SQL Azure are covered ad nauseam in dozens of places. For my initial foray here I want to talk about two things.<\/p>\n<p>A. Creating a database with the tools we all know and<\/p>\n<p>B. Creating tables in the new database.<\/p>\n<p>The tools we will use are the SQL Azure Management portal, SQL Server Management Studio and Visual Studio 2010. So let&#8217;s look first at creating a database.<\/p>\n<h3>SQL Azure Management Portal<\/h3>\n<p>I&#8217;m going to assume that you&#8217;re already created a SQL Azure server and taken note of its name, url, administrator name and password because you will need these. Note that you cannot log in to a SQL Azure instance with Windows Authentication. You must use a user name and password. Here&#8217;s a sample of what you might see.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1185\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az1.png\" width=\"500\" height=\"275\" alt=\"1638-az1.png\" \/><\/a><\/p>\n<p>When logging in, your user name will take the form (using the information above) of dncadmin@i46it8qgsh. Note that you cannot use admin, administrator or any of several other short, easily-remembered, names for your Administrator Login name. Actually all of the rules that Microsoft employs make perfect sense because you will certainly want your database as secure as possible.<\/p>\n<h3>Create a database using the Portal<\/h3>\n<p>From the above screen, use the ribbon <em>Database Create<\/em> button in the ribbon to create your SQL Azure database. My suggestion is that you always use the Portal to create your databases. The Create button presents the following screen:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1186\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az2.png\" width=\"434\" height=\"235\" alt=\"1638-az2.png\" \/><\/a><\/p>\n<p>SQL Azure has a concept you won&#8217;t see in an on-premise SQL. That concept is size. The size is determined from this screen. The Web Edition offers 2 sizes:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1187\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az3.png\" width=\"437\" height=\"237\" alt=\"1638-az3.png\" \/><\/a><\/p>\n<p>The business edition started out with 10, 20, 30, 40 and 50 GB sizes. That has now been increased to 7 sizes as shown here:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1188\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az4.png\" width=\"434\" height=\"356\" alt=\"1638-az4.png\" \/><\/a><\/p>\n<p>For this discussion I chose a Web Edition with a size of 1GB.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1189\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az5.png\" width=\"435\" height=\"234\" alt=\"1638-az5.png\" \/><\/a><\/p>\n<p>And now we have a new database. The point is that the SQL Azure Portal makes the creation of a database a simple selection of two options, Edition and Maximum Size, and the entry of a name.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1190\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az6.png\" width=\"501\" height=\"284\" alt=\"1638-az6.png\" \/><\/a><\/p>\n<p>You can do a number of things now such as <em>Test Connectivity<\/em>.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1191\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az7.png\" width=\"511\" height=\"384\" alt=\"1638-az7.png\" \/><\/a><\/p>\n<p>You can also <em>Create<\/em> another database, <em>Drop<\/em> the database or <em>Manage<\/em> the database. So let&#8217;s explore <em>Manage<\/em> for a minute.<\/p>\n<h3>Manage your database using the portal<\/h3>\n<p>First, you will need your Administrator Login from the properties and your password to open the <em>Manage<\/em> operation. Note that this is a Silverlight application. Click the <em>Manage<\/em> button in the ribbon to get the Logon screen.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1192\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az8.png\" width=\"491\" height=\"333\" alt=\"1638-az8.png\" \/><\/a><\/p>\n<p>SQL Manager fills in the Server and Database information. Note that the User name is the Administrator Logon name with @ and the unique part of the server name appended. Once you&#8217;re logged on you get a very busy screen with a bunch of selections. We&#8217;re going to explore the design part for this discussion but you can always explore on your own if you like.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az9-1024x587.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1193\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az9-1024x587.png\" width=\"498\" height=\"285\" alt=\"1638-az9-1024x587.png\" \/><\/a><\/p>\n<p>In the lower left you will see Overview, Administrator, and Design. For now click the <em>Design<\/em> button to get the following screen.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1194\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az10.png\" width=\"498\" height=\"222\" alt=\"1638-az10.png\" \/><\/a><\/p>\n<p>And suddenly we&#8217;re back to something most of us are familiar with:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1195\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az11.png\" width=\"501\" height=\"222\" alt=\"1638-az11.png\" \/><\/a><\/p>\n<p>You can change the table name and begin designing your new table. &#160;Interestingly there are 36 data types, very similar to plain old SQL Server:<\/p>\n<p>bigint, binary, bit, char, date, datetime, datetime2, datetimeoffset, decimal, float, geography, geometry, hierarchyid, image, int, money, nchar, ntext, numeric, nvarchar, nvarchar(max), real, smalldatetime, smallint, smallmoney, sql_variant, sysname, text, time, timestamp, tinyint,&#160; uniqueidentifier, varbinary(max), varchar, varchar(max) and xml<\/p>\n<p>Obviously you&#8217;ll be familiar with many of these types but we&#8217;ll get into the meaning of all of these another time. Here&#8217;s a sample Customer table filled in. Again this is all very familiar territory with Wizards used for easing the work.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1196\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az12.png\" width=\"498\" height=\"361\" alt=\"1638-az12.png\" \/><\/a><\/p>\n<h2><\/h2>\n<h2>SQL Server Management Studio<\/h2>\n<p>Now let&#8217;s explore the very different experience using SQL Server Management Studio. For this example I&#8217;m using SQL Server 2012 Management Studio just to ensure we have the latest updates.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1197\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az13.png\" width=\"426\" height=\"322\" alt=\"1638-az13.png\" \/><\/a><\/p>\n<p>Things start out quite normally except that Windows Authentication is not allowed. The Server Name is the full name from your Azure portal and the Login name follows the Administrator Login name followed by the @ symbol and the unique part of the server name. But before we go any further let&#8217;s explore what we have when logging on to a local SQL Server instance. Right clicking <em>Databases<\/em> brings up this dialog with a plethora of options.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1198\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az14.png\" width=\"233\" height=\"232\" alt=\"1638-az14.png\" \/><\/a><\/p>\n<p>Selecting <em>New Database<\/em>&#8230; brings up the following wizard. You set various things in a Wizard fashion and Voila! you have a new database.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az15.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1199\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az15.png\" width=\"499\" height=\"455\" alt=\"1638-az15.png\" \/><\/a><\/p>\n<p>On the other hand connecting to a SQL Azure instance using SSMS gives you the following options when right clicking <em>Databases<\/em>:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1200\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az16.png\" width=\"236\" height=\"133\" alt=\"1638-az16.png\" \/><\/a><\/p>\n<p>So you get an extremely truncated group of options. Making things worse, if you select <em>New Database<\/em>&#8230; you get whoops!!! A SQL Script instance:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1201\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az17.png\" width=\"500\" height=\"229\" alt=\"1638-az17.png\" \/><\/a><\/p>\n<p>But let&#8217;s back up a minute and do some additional things. When you log in to SSMS you need to add some parameters. When a SQL Azure instance is built that instance includes a MASTER database. When you log on you need to log on in the master context so click the <em>Options<\/em> button on the log on screen. You will get the following:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az18.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1202\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az18.png\" width=\"426\" height=\"501\" alt=\"1638-az18.png\" \/><\/a><\/p>\n<p>Select the <em>Connection Properties<\/em> tab for this:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az19.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1203\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az19.png\" width=\"426\" height=\"501\" alt=\"1638-az19.png\" \/><\/a><\/p>\n<p>On the dropdown to the right of <em>Connect to database<\/em> select &lt;Browse Server&#8230;&gt;. &#160;After a few seconds you will get this:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az20.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1204\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az20.png\" width=\"352\" height=\"362\" alt=\"1638-az20.png\" \/><\/a><\/p>\n<p>Highlight <em>master <\/em>to get the following screen and also check <em>Encrypt connection<\/em>. Now click the <em>Connect <\/em>button to proceed.<\/p>\n<h3>Creating a database using SSMS<\/h3>\n<p>When you are connected to the master database, you can create new databases on the server and modify or drop existing databases. The steps below describe how to accomplish several common database management tasks through SSMS. They assume that you are connected to the master database with the server-level principal login that you created when you set up your server.<\/p>\n<p>When you right click on <em>databases<\/em> you get the following script:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1205\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az21.png\" width=\"498\" height=\"169\" alt=\"1638-az21.png\" \/><\/a><\/p>\n<p>You can use the <code>CREATE DATABASE<\/code> statement to create a new database. The statement below creates a new database named mySSMSTestDB, and specifies that it is a Business Edition database with a maximum size of 20 GB.<\/p>\n<pre class=\"lang:tsql theme:ssms2012\">CREATE DATABASE mySSMSTestDB\n(MAXSIZE=20GB, EDITION='Business')<\/pre>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az22.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1206\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az22.png\" width=\"499\" height=\"350\" alt=\"1638-az22.png\" \/><\/a><\/p>\n<p>You can then use the <strong>ALTER DATABASE<\/strong> statement to modify that database, for example if you want to change the name, maximum size, or edition (business or web) of the database. The statement below modifies the database you created in the previous step to change the maximum size to 5 GB and change the edition to web.<\/p>\n<pre class=\"lang:tsql theme:ssms2012\">ALTER DATABASE mySSMSTestDB\nMODIFY\n(MAXSIZE=5GB, Edition='Web')<\/pre>\n<p>You could finally use the <code>DROP DATABASE<\/code> statement to delete the database. The statement below deletes the mySSMSTestDB database.<\/p>\n<pre class=\"lang:tsql theme:ssms2012\">DROP DATABASE mySSMSTestDB<\/pre>\n<p>The master database has the sys.databases view that can be used to view the details of all databases. To view all existing databases, use the following statement.<\/p>\n<pre class=\"lang:tsql theme:ssms2012\">SELECT * FROM sys.databases<\/pre>\n<p>In SQL Azure the USE statement is not supported. You need to establish a connection directly to the relevant database. Also Transact-SQL statements that create or modify databases must be run within their own batch and cannot be grouped.<\/p>\n<p>Aside from the fact that you create and alter databases using script &#8211; it&#8217;s not too bad but I personally still prefer the wizards. The problem is it doesn&#8217;t get better.<\/p>\n<p>NOTE: I did notice one oddity. Sometimes <code>'Web'<\/code> and <code>'Business'<\/code> work and sometimes they work without the quotes. Your mileage may vary but if it fails one way, try it the other.<\/p>\n<h3>Creating tables using SSMS<\/h3>\n<p>If you select the new database and expand it, then right click <em>Tables<\/em> you will get the following and I&#8217;m quitting here. For you dyed-in-the-wool scripting fans this will probably work but I lost it at this point.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1207\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az23.png\" width=\"503\" height=\"198\" alt=\"1638-az23.png\" \/><\/a><\/p>\n<h2><\/h2>\n<h2>Creating databases using Visual Studio 11<\/h2>\n<p>My tool of choice when working with local SQL instances has always been SQL Server Management Studio. I generate databases and tables using that tool and then deploy them using Visual Studio. I always knew that VS provided some good database tools &#8211; I just didn&#8217;t use them. Now, I&#8217;m going to go a little crazy. I will stick to one small SQL Azure database (Web edition, 1 GB). I&#8217;m going to add a single Customer table and I&#8217;m going to see if I can deploy a LightSwitch application using that database. I am NOT going to get fancy. If this works I&#8217;ll be proud and we will both have learned something (I hope). To duplicate this you will need the Visual Studio 11 Beta.<\/p>\n<h3>Creating the database<\/h3>\n<p>I&#8217;m going to connect to my SQL Azure SQL instance and create a single database that I&#8217;m calling <strong>MyLightSwitchDB<\/strong>, so let&#8217;s fire up Visual Studio 11 and get started. The interface is likely to surprise you if you haven&#8217;t used it before. It comes in two flavors, dark or light. I&#8217;m using the light interface. Gone are the pretty icons. Instead most are very austere and functional.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1208\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az24.png\" width=\"397\" height=\"287\" alt=\"1638-az24.png\" \/><\/a><\/p>\n<p>Clicking the icon that looks like an American wall-socket plug with a + sign (3rd from the left) will bring up the Add Connection dialog.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1209\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az25.png\" width=\"451\" height=\"662\" alt=\"1638-az25.png\" \/><\/a><\/p>\n<p>Once filled out just click <em>OK<\/em>. Because the database does not exist you will get the following:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az26.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1210\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az26.png\" width=\"473\" height=\"202\" alt=\"1638-az26.png\" \/><\/a><\/p>\n<p>Again click <em>Yes<\/em> and the system will create your database in SQL Azure. You can verify this by going to the Azure portal and checking the database section. You should see a new Web edition DB with 1GB size.<\/p>\n<p>In Visual Studio 11 SERVER EXPLORER if you right click the database name you can shift to SQL SERVER OBJECT EXPLORER which shows the following view.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az27.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1211\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az27.png\" width=\"336\" height=\"388\" alt=\"1638-az27.png\" \/><\/a><\/p>\n<p>At this point you can right click <em>Tables<\/em> and elect to <em>Add New Table<\/em>&#8230;.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az28-1024x690.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1212\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az28-1024x690.png\" width=\"501\" height=\"337\" alt=\"1638-az28-1024x690.png\" \/><\/a><\/p>\n<p>Now you have all of the goodness of SQL Server Management Studio with the addition of on the fly script generation. Start by changing [Table] in the script view to [Customers]. Also change the primary key name to CustomerID. Truthfully, I struggled for a bit finding where to set the identity specification but it&#8217;s in the PROPERTIES windows. That window has little right pointing arrows in the bar at the left of the window. Clicking that arrow expands the choices thusly:<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az29.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1213\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az29.png\" width=\"263\" height=\"291\" alt=\"1638-az29.png\" \/><\/a><\/p>\n<p>Setting (Is Identity) to <strong>True<\/strong> fills in the Increment and Seed values with suggested values of 1 which is fine here. It also changes the script being generated to an appropriate value.<\/p>\n<p>Now fill in the additional values and click the <em>Update<\/em> arrow at the top of the screen.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az30.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1214\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az30.png\" width=\"445\" height=\"685\" alt=\"1638-az30.png\" \/><\/a><\/p>\n<p>You have the option of generating and executing an update script or simply updating the database. Once you&#8217;ve updated the SQL Azure database you can move on by opening a LightSwitch application.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1215\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az31.png\" width=\"499\" height=\"344\" alt=\"1638-az31.png\" \/><\/a><\/p>\n<p>Once the application is created select the <em>Attach to External Data Source<\/em> option.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az32.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1216\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az32.png\" width=\"499\" height=\"393\" alt=\"1638-az32.png\" \/><\/a><\/p>\n<p>Highlight Database as shown and click <em>Next<\/em>.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az33.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1217\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az33.png\" width=\"451\" height=\"662\" alt=\"1638-az33.png\" \/><\/a><\/p>\n<p>You will need to fill in the Server name and credentials. The Connect to a database dropdown will at that point offer MyLightSwitchDB as selection. On clicking <em>OK<\/em> you will get a new dialog that will take a little time to populate.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az34.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1218\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az34.png\" width=\"499\" height=\"393\" alt=\"1638-az34.png\" \/><\/a><\/p>\n<p>Once populated, make the selections shown above and click<em> finish<\/em>. You should see the following screen indicating that things have gone as expected.<\/p>\n<p><a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az35-1024x678.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1219\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1638-az35-1024x678.png\" width=\"501\" height=\"331\" alt=\"1638-az35-1024x678.png\" \/><\/a><\/p>\n<p>With the problems I&#8217;ve had over the last few weeks with both Azure and LightSwitch this exercise has made me feel very good about future prospects. At this point I would suggest making a Detail Screen and an Editable Grid Screen so you can explore LightSwitch connected to SQL Azure in more detail.<\/p>\n<p>This article has been mostly about the creation of SQL Azure databases and the generation of tables using several available tools. At this point using the Azure Management Portal probably offers the best options overall. Visual Studio 11 has made some large strides into the management of SQL Azure as we&#8217;ve shown above. My favorite tool to this point, SQL Server Management Studio, &#160;can be used but the Wizards are not available at this point even with the SQL 2012 version. It&#8217;s possible this will change but for me it has now become a choice of the Azure portal or Visual Studio 11.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>So how easy is it to set up a database-driven application on Azure, using the tools that one is familar with. There are several different ways of doing it, and Bud decides to find out which is the best way&hellip;<\/p>\n","protected":false},"author":29013,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[5364,5336,4168,4359],"coauthors":[48709],"class_list":["post-1479","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-azure","tag-cloud","tag-database","tag-development"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/29013"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=1479"}],"version-history":[{"count":4,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1479\/revisions"}],"predecessor-version":[{"id":90122,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1479\/revisions\/90122"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=1479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=1479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=1479"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=1479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}